Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2022-11-28 02:34:58
Exec Total Coverage
Lines: 6719 11404 58.9%
Functions: 66 105 62.9%
Branches: 3961 9441 42.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #ifndef __GTHREAD_HIDE_WIN32API
12 #define __GTHREAD_HIDE_WIN32API 1
13 #endif //prevent indirectly including windows.h
14
15 #include "precompiled.h" //always first
16 10
17 #include <stdio.h>
18 #include <string.h>
19 #include <string>
20 #include <map>
21 #include <vector>
22 #include <assert.h>
23
24
25 #include "metadata/sigs/devsig.h.sig"
26 #include "metadata/sigs/compilersig.h.sig"
27 #include "metadata/versionsig.h"
28 #include "base/zc_alleg.h"
29 #include "base/zdefs.h"
30 #include "base/colors.h"
31 #include "tiles.h"
32 #include "base/zsys.h"
33 #include "qst.h"
34 //#include "zquest.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "font.h"
38 #include "zc_custom.h"
39 #include "sfx.h"
40 #include "md5.h"
41 #include "ffscript.h"
42 #include "particles.h"
43 #include "dialog/alert.h"
44 //FFScript FFCore;
45 extern FFScript FFCore;
46 extern ZModule zcm;
47 extern zcmodule moduledata;
48 extern uint8_t __isZQuest;
49 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
50 extern particle_list particles;
51 extern void setZScriptVersion(int32_t s_version);
52 //FFSCript FFEngine;
53
54 int32_t temp_ffscript_version = 0;
55 static bool read_ext_zinfo = false, read_zinfo = false;
56 static bool loadquest_report = false;
57 static char const* loading_qst_name = NULL;
58 static byte loading_qst_num = 0;
59
60 #ifdef _MSC_VER
61 #define strncasecmp _strnicmp
62 #endif
63
64 #ifndef _AL_MALLOC
65 #define _AL_MALLOC(a) _al_malloc(a)
66 #define _AL_FREE(a) _al_free(a)
67 #endif
68
69 using std::string;
70 using std::pair;
71
72 // extern bool debug;
73 extern int32_t hero_animation_speed; //lower is faster animation
74 extern std::vector<mapscr> TheMaps;
75 extern zcmap *ZCMaps;
76 extern MsgStr *MsgStrings;
77 extern DoorComboSet *DoorComboSets;
78 extern dmap *DMaps;
79 extern newcombo *combobuf;
80 extern byte *colordata;
81 //extern byte *tilebuf;
82 extern tiledata *newtilebuf;
83 extern byte *trashbuf;
84 extern itemdata *itemsbuf;
85 extern wpndata *wpnsbuf;
86 extern comboclass *combo_class_buf;
87 extern guydata *guysbuf;
88 extern ZCHEATS zcheats;
89 extern zinitdata zinit;
90 extern char palnames[MAXLEVELS][17];
91 extern int32_t memrequested;
92 extern char *byte_conversion(int32_t number, int32_t format);
93 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
94 10 string zScript;
95
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
20 std::map<int32_t, script_slot_data > ffcmap;
96 10 std::map<int32_t, script_slot_data > globalmap;
97 10 std::map<int32_t, script_slot_data > genericmap;
98 10 std::map<int32_t, script_slot_data > itemmap;
99 10 std::map<int32_t, script_slot_data > npcmap;
100 10 std::map<int32_t, script_slot_data > ewpnmap;
101 10 std::map<int32_t, script_slot_data > lwpnmap;
102 10 std::map<int32_t, script_slot_data > playermap;
103 10 std::map<int32_t, script_slot_data > dmapmap;
104 10 std::map<int32_t, script_slot_data > screenmap;
105 10 std::map<int32_t, script_slot_data > itemspritemap;
106 10 std::map<int32_t, script_slot_data > comboscriptmap;
107 void free_newtilebuf();
108 bool combosread=false;
109 bool mapsread=false;
110 bool fixffcs=false;
111 bool fixpolsvoice=false;
112
113 10 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
114 10 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
115 10 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
116 10 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
117
118 char qstdat_string[2048] = { 0 };
119
120 static zinfo* load_tmp_zi = NULL;
121
122 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
123 const byte clavio[9]={97,109,111,110,103,117,115,0};
124
125 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
126 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
127
128 extern combo_alias combo_aliases[MAXCOMBOALIASES];
129 extern combo_pool combo_pools[MAXCOMBOPOOLS];
130 const char *qst_error[] =
131 {
132 "OK","File not found","Invalid quest file",
133 "Version not supported","Obsolete version",
134 "Missing new data" , /* but let it pass in ZQuest */
135 "Internal error occurred", "Invalid password",
136 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
137 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
138 };
139
140 //for legacy quests -DD
141 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
142 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
143 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDINSFIRE, ssiFARORESWIND, ssiNAYRUSLOVE, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
144 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
145 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
146 };
147
148 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
149
150
151 void delete_combo_aliases()
152 {
153 for(int32_t j(0); j<256; j++)
154 {
155 if(combo_aliases[j].combos != NULL)
156 {
157 delete[] combo_aliases[j].combos;
158 combo_aliases[j].combos=NULL;
159 }
160
161 if(combo_aliases[j].csets != NULL)
162 {
163 delete[] combo_aliases[j].csets;
164 combo_aliases[j].csets=NULL;
165 }
166 }
167
168 }
169
170 char *byte_conversion(int32_t number, int32_t format)
171 {
172 static char num_str[40];
173
174 if(format==-1) //auto
175 {
176 format=1; //bytes
177
178 if(number>1024)
179 {
180 format=2; //kilobytes
181 }
182
183 if(number>1024*1024)
184 {
185 format=3; //megabytes
186 }
187
188 if(number>1024*1024*1024)
189 {
190 format=4; //gigabytes (dude, what are you doing?)
191 }
192 }
193
194 switch(format)
195 {
196 case 1: //bytes
197 sprintf(num_str,"%db",number);
198 break;
199
200 case 2: //kilobytes
201 sprintf(num_str,"%.2fk",float(number)/1024);
202 break;
203
204 case 3: //megabytes
205 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
206 break;
207
208 case 4: //gigabytes
209 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
210 break;
211
212 default:
213 exit(1);
214 break;
215 }
216
217 return num_str;
218 }
219
220 140 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
221 {
222 static char num_str1[40];
223 static char num_str2[40];
224 static char num_str[80];
225
226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(format1==-1) //auto
227 {
228 140 format1=1; //bytes
229
230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(number1>1024)
231 {
232 140 format1=2; //kilobytes
233 140 }
234
235
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 40 times.
140 if(number1>1024*1024)
236 {
237 40 format1=3; //megabytes
238 40 }
239
240
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(number1>1024*1024*1024)
241 {
242 format1=4; //gigabytes (dude, what are you doing?)
243 }
244 140 }
245
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(format2==-1) //auto
247 {
248 140 format2=1; //bytes
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(number2>1024)
251 {
252 140 format2=2; //kilobytes
253 140 }
254
255
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 130 times.
140 if(number2>1024*1024)
256 {
257 130 format2=3; //megabytes
258 130 }
259
260
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(number2>1024*1024*1024)
261 {
262 format2=4; //gigabytes (dude, what are you doing?)
263 }
264 140 }
265
266
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
140 switch(format1)
267 {
268 case 1: //bytes
269 sprintf(num_str1,"%db",number1);
270 break;
271
272 case 2: //kilobytes
273 100 sprintf(num_str1,"%.2fk",float(number1)/1024);
274 100 break;
275
276 case 3: //megabytes
277 40 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
278 40 break;
279
280 case 4: //gigabytes
281 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
282 break;
283
284 default:
285 exit(1);
286 break;
287 }
288
289
2/5
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
✗ Branch 4 not taken.
140 switch(format2)
290 {
291 case 1: //bytes
292 sprintf(num_str2,"%db",number2);
293 break;
294
295 case 2: //kilobytes
296 10 sprintf(num_str2,"%.2fk",float(number2)/1024);
297 10 break;
298
299 case 3: //megabytes
300 130 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
301 130 break;
302
303 case 4: //gigabytes
304 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
305 break;
306
307 default:
308 exit(1);
309 break;
310 }
311
312 140 sprintf(num_str, "%s/%s", num_str1, num_str2);
313 140 return num_str;
314 }
315
316 char *ordinal(int32_t num)
317 {
318 static const char *ending[4] = {"st","nd","rd","th"};
319 static char ord_str[8];
320
321 char *end;
322 int32_t t=(num%100)/10;
323 int32_t n=num%10;
324
325 if(n>=1 && n<4 && t!=1)
326 end = (char *)ending[n-1];
327 else
328 end = (char *)ending[3];
329
330 sprintf(ord_str,"%d%s",num%10000,end);
331 return ord_str;
332 }
333
334 10 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
335 {
336 int32_t ret;
337 10 *version=0;
338 10 *build=0;
339 10 byte temp_map_count=map_count;
340 byte temp_midi_flags[MIDIFLAGS_SIZE];
341 10 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
342
343 zquestheader tempheader;
344
345
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!f)
346 {
347 return qe_invalid;
348 }
349
350 10 ret=readheader(f, &tempheader, true);
351
352
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(ret)
353 {
354 return ret;
355 }
356
357 10 map_count=temp_map_count;
358 10 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
359 10 *version=tempheader.zelda_version;
360 10 *build=tempheader.build;
361 10 return 0;
362 10 }
363
364
365 10 bool find_section(PACKFILE *f, int32_t section_id_requested)
366 {
367
368
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!f)
369 {
370 return false;
371 }
372
373 int32_t section_id_read;
374 10 bool catchup=false;
375 word dummy;
376 byte tempbyte;
377 char tempbuf[65536];
378
379
380
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 switch(section_id_requested)
381 {
382 case ID_RULES:
383 case ID_STRINGS:
384 case ID_MISC:
385 case ID_TILES:
386 case ID_COMBOS:
387 case ID_CSETS:
388 case ID_MAPS:
389 case ID_DMAPS:
390 case ID_DOORS:
391 case ID_ITEMS:
392 case ID_WEAPONS:
393 case ID_COLORS:
394 case ID_ICONS:
395 case ID_INITDATA:
396 case ID_GUYS:
397 case ID_MIDIS:
398 case ID_CHEATS:
399 10 break;
400
401 default:
402 al_trace("Bad section requested!\n");
403 return false;
404 break;
405 }
406
407 dword section_size;
408
409 //section id
410
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!p_mgetl(&section_id_read,f,true))
411 {
412 return false;
413 }
414
415
1/2
✓ Branch 0 taken 2040 times.
✗ Branch 1 not taken.
2040 while(!pack_feof(f))
416 {
417
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 2030 times.
2040 switch(section_id_read)
418 {
419 case ID_RULES:
420 case ID_STRINGS:
421 case ID_MISC:
422 case ID_TILES:
423 case ID_COMBOS:
424 case ID_CSETS:
425 case ID_MAPS:
426 case ID_DMAPS:
427 case ID_DOORS:
428 case ID_ITEMS:
429 case ID_WEAPONS:
430 case ID_COLORS:
431 case ID_ICONS:
432 case ID_INITDATA:
433 case ID_GUYS:
434 case ID_MIDIS:
435 case ID_CHEATS:
436 10 catchup=false;
437 10 break;
438
439 default:
440 2030 break;
441 }
442
443
444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2040 times.
2040 while(catchup)
445 {
446 //section id
447 section_id_read=(section_id_read<<8);
448
449 if(!p_getc(&tempbyte,f,true))
450 {
451 return false;
452 }
453
454 section_id_read+=tempbyte;
455 }
456
457
1/2
✓ Branch 0 taken 2040 times.
✗ Branch 1 not taken.
2040 if(section_id_read==section_id_requested)
458 {
459 return true;
460 }
461 else
462 {
463 //section version info
464
1/2
✓ Branch 0 taken 2040 times.
✗ Branch 1 not taken.
2040 if(!p_igetw(&dummy,f,true))
465 {
466 return false;
467 }
468
469
1/2
✓ Branch 0 taken 2040 times.
✗ Branch 1 not taken.
2040 if(!p_igetw(&dummy,f,true))
470 {
471 return false;
472 }
473
474 //section size
475
1/2
✓ Branch 0 taken 2040 times.
✗ Branch 1 not taken.
2040 if(!p_igetl(&section_size,f,true))
476 {
477 return false;
478 }
479
480 //pack_fseek(f, section_size);
481
2/2
✓ Branch 0 taken 655350 times.
✓ Branch 1 taken 2040 times.
657390 while(section_size>65535)
482 {
483 655350 pfread(tempbuf,65535,f,true);
484 655350 tempbuf[65535]=0;
485 655350 section_size-=65535;
486 }
487
488
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 50 times.
2040 if(section_size>0)
489 {
490 50 pfread(tempbuf,section_size,f,true);
491 50 tempbuf[section_size]=0;
492 50 }
493 }
494
495 //section id
496
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 2030 times.
2040 if(!p_mgetl(&section_id_read,f,true))
497 {
498 10 return false;
499 }
500 }
501
502 return false;
503 10 }
504
505
506
507
508
509 10 bool valid_zqt(PACKFILE *f)
510 {
511
512 //word tiles_used;
513 //word combos_used;
514 //open the file
515 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!f)
517 return false;
518
519 //for now, everything else is valid
520 10 return true;
521
522 /*int16_t version;
523 byte build;
524
525 //read the version and make sure it worked
526 if(!p_igetw(&version,f,true))
527 {
528 goto error;
529 }
530
531 //read the build and make sure it worked
532 if(!p_getc(&build,f,true))
533 goto error;
534
535 //read the tile info and make sure it worked
536 if(!p_igetw(&tiles_used,f,true))
537 {
538 goto error;
539 }
540
541 for (int32_t i=0; i<tiles_used; i++)
542 {
543 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
544 {
545 goto error;
546 }
547 }
548
549 //read the combo info and make sure it worked
550 if(!p_igetw(&combos_used,f,true))
551 {
552 goto error;
553 }
554 for (int32_t i=0; i<combos_used; i++)
555 {
556 if(!pfread(trashbuf,sizeof(newcombo),f,true))
557 {
558 goto error;
559 }
560 }
561
562 //read the palette info and make sure it worked
563 for (int32_t i=0; i<48; i++)
564 {
565 if(!pfread(trashbuf,newpdTOTAL,f,true))
566 {
567 goto error;
568 }
569 }
570 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
571 {
572 goto error;
573 }
574 for (int32_t i=0; i<MAXLEVELS; i++)
575 {
576 if(!pfread(trashbuf,PALNAMESIZE,f,true))
577 {
578 goto error;
579 }
580 }
581
582 //read the sprite info and make sure it worked
583 for (int32_t i=0; i<MAXITEMS; i++)
584 {
585 if(!pfread(trashbuf,sizeof(itemdata),f,true))
586 {
587 goto error;
588 }
589 }
590
591 for (int32_t i=0; i<MAXWPNS; i++)
592 {
593 if(!pfread(trashbuf,sizeof(wpndata),f,true))
594 {
595 goto error;
596 }
597 }
598
599 //read the triforce pieces info and make sure it worked
600 for (int32_t i=0; i<8; ++i)
601 {
602 if(!p_getc(&trashbuf,f,true))
603 {
604 goto error;
605 }
606 }
607
608
609
610 //read the game icons info and make sure it worked
611 for (int32_t i=0; i<4; ++i)
612 {
613 if(!p_igetw(&trashbuf,f,true))
614 {
615 goto error;
616 }
617 }
618
619 //read the misc colors info and map styles info and make sure it worked
620 if(!pfread(trashbuf,sizeof(zcolors),f,true))
621 {
622 goto error;
623 }
624
625 //read the template screens and make sure it worked
626 byte num_maps;
627 if(!p_getc(&num_maps,f,true))
628 {
629 goto error;
630 }
631 for (int32_t i=0; i<TEMPLATES; i++)
632 {
633 if(!pfread(trashbuf,sizeof(mapscr),f,true))
634 {
635 goto error;
636 }
637 }
638 if (num_maps>1) //dungeon templates
639 {
640 for (int32_t i=0; i<TEMPLATES; i++)
641 {
642 if(!pfread(trashbuf,sizeof(mapscr),f,true))
643 {
644 goto error;
645 }
646 }
647 }
648
649 //yay! it worked! close the file and say everything was ok.
650 pack_fclose(f);
651 return true;
652
653 error:
654 pack_fclose(f);
655 return false;*/
656 10 }
657
658 bool valid_zqt(const char *filename)
659 {
660 PACKFILE *f=NULL;
661 bool isvalid;
662 char deletefilename[1024];
663 deletefilename[0]=0;
664 int32_t error;
665 f=open_quest_file(&error, filename, deletefilename, true, true,false);
666
667 if(!f)
668 {
669 // setPackfilePassword(NULL);
670 return false;
671 }
672
673 isvalid=valid_zqt(f);
674
675 if(deletefilename[0])
676 {
677 delete_file(deletefilename);
678 }
679
680 // setPackfilePassword(NULL);
681 return isvalid;
682 }
683
684 35 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, char *deletefilename, bool compressed,bool encrypted, bool show_progress)
685 {
686 char tmpfilename[L_tmpnam];
687 35 temp_name(tmpfilename);
688 char percent_done[30];
689 35 int32_t current_method=0;
690
691 PACKFILE *f;
692 35 const char *passwd= encrypted ? datapwd : "";
693
694 // oldquest flag is set when an unencrypted qst file is suspected.
695 35 bool oldquest = false;
696 int32_t ret;
697
698
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(show_progress)
699 {
700 box_start(1, "Loading Quest", lfont, font, true);
701 }
702
703 35 box_out("Loading Quest: ");
704 //if(strncasecmp(filename, "qst.dat", 7)!=0)
705 //int32_t qstdat_str_size = 0;
706 //for ( int32_t q = 0; q < 255; q++ ) //find the length of the string
707 //{
708 // if ( moduledata.datafiles[qst_dat][q] != 0 ) qstdat_str_size++;
709 // else break;
710 //}
711 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], 7)!=0)
712 35 al_trace("Trying to do strncasecmp() when loading a quest\n");
713 35 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
714 35 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
715 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], qstdat_filename_size)!=0)
716
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
717 {
718 35 box_out(filename);
719 35 }
720 else
721 {
722 box_out("new quest"); // Or whatever
723 }
724 35 box_out("...");
725 35 box_eol();
726 35 box_eol();
727
728
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(encrypted)
729 {
730 35 box_out("Decrypting...");
731 35 box_save_x();
732 35 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, strstr(filename, ".dat#")!=NULL, passwd);
733
734
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(ret)
735 {
736 switch(ret)
737 {
738 case 1:
739 box_out("error.");
740 box_eol();
741 box_end(true);
742 *open_error=qe_notfound;
743 return NULL;
744
745 case 2:
746 box_out("error.");
747 box_eol();
748 box_end(true);
749 *open_error=qe_internal;
750 return NULL;
751 // be sure not to delete tmpfilename now...
752 }
753
754 if(ret==5) //old encryption?
755 {
756 current_method++;
757 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
758 box_out(percent_done);
759 box_load_x();
760 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
761 }
762
763 if(ret==5) //old encryption?
764 {
765 current_method++;
766 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
767 box_out(percent_done);
768 box_load_x();
769 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
770 }
771
772 if(ret==5) //old encryption?
773 {
774 current_method++;
775 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
776 box_out(percent_done);
777 box_load_x();
778 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
779 }
780
781 if(ret==5) //old encryption?
782 {
783 current_method++;
784 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
785 box_out(percent_done);
786 box_load_x();
787 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
788 }
789
790 if(ret)
791 {
792 oldquest = true;
793 passwd="";
794 }
795 }
796
797 35 box_out("okay.");
798 35 box_eol();
799 35 }
800 else
801 {
802 oldquest = true;
803 }
804
805 35 box_out("Opening...");
806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
807
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!f)
808 {
809 if((compressed==1)&&(errno==EDOM))
810 {
811 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
812 }
813
814 if(!f)
815 {
816 if(!oldquest)
817 {
818 delete_file(tmpfilename);
819 }
820 box_out("error.");
821 box_eol();
822 box_end(true);
823 *open_error=qe_invalid;
824 return NULL;
825 }
826 }
827
828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!oldquest)
829 {
830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(deletefilename)
831 35 sprintf(deletefilename, "%s", tmpfilename);
832 35 }
833
834 35 box_out("okay.");
835 35 box_eol();
836
837 35 return f;
838 35 }
839
840 10 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
841 {
842 char *filename;
843 10 PACKFILE *f=NULL;
844 10 int32_t open_error=0;
845 10 deletefilename[0]=0;
846
847 10 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
848 10 strcat(qstdat_string,"#NESQST_NEW_QST");
849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(Header->templatepath[0]==0)
850 {
851 10 filename=(char *)malloc(2048);
852 //strcpy(filename, "qst.dat#NESQST_NEW_QST");
853 10 strcpy(filename, qstdat_string);
854 10 }
855 else
856 {
857 filename=Header->templatepath;
858 }
859
860 10 f=open_quest_file(&open_error, filename, deletefilename, true, true,false);
861
862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(Header->templatepath[0]==0)
863 {
864 10 free(filename);
865 10 }
866
867
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!f)
868 {
869 return NULL;
870 }
871
872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(validate)
873 {
874
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!valid_zqt(f))
875 {
876 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,lfont);
877 pack_fclose(f);
878
879 //setPackfilePassword(NULL);
880 if(deletefilename[0])
881 {
882 delete_file(deletefilename);
883 }
884
885 return NULL;
886 }
887 10 }
888
889 10 return f;
890 10 }
891
892 10 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
893 {
894 10 combosread=false;
895 10 mapsread=false;
896 10 fixffcs=false;
897
898
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 switch(section_id)
899 {
900 case ID_RULES:
901 case ID_STRINGS:
902 case ID_MISC:
903 case ID_TILES:
904 case ID_COMBOS:
905 case ID_CSETS:
906 case ID_MAPS:
907 case ID_DMAPS:
908 case ID_DOORS:
909 case ID_ITEMS:
910 case ID_WEAPONS:
911 case ID_COLORS:
912 case ID_ICONS:
913 case ID_INITDATA:
914 case ID_GUYS:
915 case ID_MIDIS:
916 case ID_CHEATS:
917 case ID_ITEMDROPSETS:
918 case ID_FAVORITES:
919 10 break;
920
921 default:
922 return false;
923 break;
924 }
925
926 int32_t ret;
927 word version, build;
928 10 PACKFILE *f=NULL;
929
930 char deletefilename[1024];
931 10 deletefilename[0]=0;
932
933 //why is this here?
934 /*
935 if(colordata==NULL)
936 return false;
937 */
938
939 //setPackfilePassword(datapwd);
940 10 f=open_quest_template(Header, deletefilename, validate);
941
942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!f) //no file, nothing to delete
943 {
944 // setPackfilePassword(NULL);
945 return false;
946 }
947
948 10 ret=get_version_and_build(f, &version, &build);
949
950
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(ret||(version==0))
951 {
952 pack_fclose(f);
953
954 if(deletefilename[0])
955 {
956 delete_file(deletefilename);
957 }
958
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!find_section(f, section_id))
964 {
965 10 al_trace("Can't find section!\n");
966 10 pack_fclose(f);
967
968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(deletefilename[0])
969 {
970 10 delete_file(deletefilename);
971 10 }
972
973 //setPackfilePassword(NULL);
974 10 return false;
975 }
976
977 switch(section_id)
978 {
979 case ID_RULES:
980 //rules
981 ret=readrules(f, Header, true);
982 break;
983
984 case ID_STRINGS:
985 //strings
986 ret=readstrings(f, Header, true);
987 break;
988
989 case ID_MISC:
990 //misc data
991 ret=readmisc(f, Header, Misc, true);
992 break;
993
994 case ID_TILES:
995 //tiles
996 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
997 break;
998
999 case ID_COMBOS:
1000 //combos
1001 clear_combos();
1002 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1003 combosread=true;
1004 break;
1005
1006 case ID_COMBOALIASES:
1007 //combos
1008 ret=readcomboaliases(f, Header, version, build, true);
1009 break;
1010
1011 case ID_CSETS:
1012 //color data
1013 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1014 break;
1015
1016 case ID_MAPS:
1017 //maps
1018 ret=readmaps(f, Header, true);
1019 mapsread=true;
1020 break;
1021
1022 case ID_DMAPS:
1023 //dmaps
1024 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1025 break;
1026
1027 case ID_DOORS:
1028 //door combo sets
1029 ret=readdoorcombosets(f, Header, true);
1030 break;
1031
1032 case ID_ITEMS:
1033 //items
1034 ret=readitems(f, version, build, true);
1035 break;
1036
1037 case ID_WEAPONS:
1038 //weapons
1039 ret=readweapons(f, Header, true);
1040 break;
1041
1042 case ID_COLORS:
1043 //misc. colors
1044 ret=readmisccolors(f, Header, Misc, true);
1045 break;
1046
1047 case ID_ICONS:
1048 //game icons
1049 ret=readgameicons(f, Header, Misc, true);
1050 break;
1051
1052 case ID_INITDATA:
1053 //initialization data
1054 ret=readinitdata(f, Header, true);
1055 break;
1056
1057 case ID_GUYS:
1058 //guys
1059 ret=readguys(f, Header, true);
1060 break;
1061
1062 case ID_MIDIS:
1063 //midis
1064 ret=readtunes(f, Header, tunes, true);
1065 break;
1066
1067 case ID_CHEATS:
1068 //cheat codes
1069 ret=readcheatcodes(f, Header, true);
1070 break;
1071
1072 case ID_ITEMDROPSETS:
1073 //item drop sets
1074 // Why is this one commented out?
1075 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1076 break;
1077
1078 case ID_FAVORITES:
1079 // favorite combos and aliases
1080 ret=readfavorites(f, version, build, true);
1081 break;
1082
1083 default:
1084 ret=-1;
1085 break;
1086 }
1087
1088 pack_fclose(f);
1089
1090 if(deletefilename[0])
1091 {
1092 delete_file(deletefilename);
1093 }
1094
1095 //setPackfilePassword(NULL);
1096 if(!ret)
1097 {
1098 return true;
1099 }
1100
1101 return false;
1102 10 }
1103
1104 bool init_tiles(bool validate, zquestheader *Header)
1105 {
1106 return init_section(Header, ID_TILES, NULL, NULL, validate);
1107 }
1108
1109 bool init_combos(bool validate, zquestheader *Header)
1110 {
1111 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1112 }
1113
1114 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1115 {
1116 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1117 }
1118
1119 25 void init_spritelists()
1120 {
1121
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(FFCore.quest_format[vZelda] < 0x255)
1122 {
1123 24 guys.setMax(255);
1124 24 items.setMax(255);
1125 24 Ewpns.setMax(255);
1126 24 Lwpns.setMax(255);
1127 24 Sitems.setMax(255);
1128 24 chainlinks.setMax(255);
1129 24 decorations.setMax(255);
1130 24 particles.setMax(255);
1131 24 }
1132 else
1133 {
1134 1 guys.setMax(255);
1135 1 items.setMax(255);
1136 1 Ewpns.setMax(255);
1137 1 Lwpns.setMax(255);
1138 1 Sitems.setMax(255);
1139 1 chainlinks.setMax(255);
1140 1 decorations.setMax(255);
1141 1 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1142 }
1143 25 }
1144
1145 10 bool reset_items(bool validate, zquestheader *Header)
1146 {
1147 10 bool ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1148
1149 //Ignore this, but don't remove it
1150 /*
1151 if (ret)
1152 for(int32_t i=0; i<MAXITEMS; i++)
1153 {
1154 reset_itembuf(&itemsbuf[i], i);
1155 }
1156 */
1157
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 10 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1172
1173 for(int32_t i=0; i<WPNCNT; i++)
1174 reset_weaponname(i);
1175
1176 return ret;
1177 }
1178
1179 bool reset_mapstyles(bool validate, miscQdata *Misc)
1180 {
1181 Misc->colors.blueframe_tile = 20044;
1182 Misc->colors.blueframe_cset = 0;
1183 Misc->colors.triforce_tile = 23461;
1184 Misc->colors.triforce_cset = 1;
1185 Misc->colors.triframe_tile = 18752;
1186 Misc->colors.triframe_cset = 1;
1187 Misc->colors.overworld_map_tile = 16990;
1188 Misc->colors.overworld_map_cset = 2;
1189 Misc->colors.HCpieces_tile = 21160;
1190 Misc->colors.HCpieces_cset = 8;
1191 Misc->colors.dungeon_map_tile = 19651;
1192 Misc->colors.dungeon_map_cset = 8;
1193 return true;
1194 }
1195
1196 bool reset_doorcombosets(bool validate, zquestheader *Header)
1197 {
1198 return init_section(Header, ID_DOORS, NULL, NULL, validate);
1199 }
1200
1201 10 int32_t get_qst_buffers()
1202 {
1203 10 memrequested+=(sizeof(mapscr)*MAPSCRS);
1204 10 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1205 10 TheMaps.resize(MAPSCRS);
1206
1207
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 10 times.
1370 for(int32_t i(0); i<MAPSCRS; i++)
1208 1360 TheMaps[i].zero_memory();
1209
1210 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1211 10 Z_message("OK\n"); // Allocating map buffer...
1212
1213 10 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1214 10 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1215
1216
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1217 return 0;
1218
1219 10 Z_message("OK\n");
1220
1221 // Allocating space for all 65535 strings uses up 10.62MB...
1222 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1223 // (Shoelace's "Hero of Dreams" uses 1415.)
1224 // So let's be a bit generous and allow 4096 initially.
1225 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1226 // I tested it and it worked without flaw on 6/6/11. - L.
1227 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1228 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1229 // See https://discord.com/channels/876899628556091432/992984989073416242
1230 10 msg_strings_size = 8192;
1231 10 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1232 10 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1233
1234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 MsgStrings = new MsgStr[msg_strings_size];
1235
1236 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1237
2/2
✓ Branch 0 taken 81920 times.
✓ Branch 1 taken 10 times.
81930 for(auto q = 0; q < msg_strings_size; ++q)
1238 {
1239 81920 MsgStrings[q].clear();
1240 81920 }
1241 10 Z_message("OK\n"); // Allocating string buffer...
1242
1243 10 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1244 10 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1245
1246
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1247 return 0;
1248
1249 10 Z_message("OK\n"); // Allocating door combo buffer...
1250
1251 10 memrequested+=(sizeof(dmap)*MAXDMAPS);
1252 10 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1253
1254
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1255 return 0;
1256
1257 10 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1258 10 Z_message("OK\n"); // Allocating dmap buffer...
1259
1260 10 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1261 10 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1262
1263
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1264 return 0;
1265
1266 10 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1267 10 Z_message("OK\n"); // Allocating combo buffer...
1268
1269 10 memrequested+=(psTOTAL255);
1270 10 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1271
1272
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1273 return 0;
1274
1275 10 Z_message("OK\n"); // Allocating color data buffer...
1276
1277 10 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1278 10 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1279
1280 10 free_newtilebuf();
1281
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1282 return 0;
1283
1284 10 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1285 //Z_message("Performed memset on tiles\n");
1286 10 clear_tiles(newtilebuf);
1287 //Z_message("Performed clear_tiles()\n");
1288 10 Z_message("OK\n"); // Allocating tile buffer...
1289
1290
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(is_zquest())
1291 {
1292 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1293 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1294
1295 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1296 return 0;
1297
1298 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1299 clear_tiles(grabtilebuf);
1300 Z_message("OK\n"); // Allocating tile grab buffer...
1301 }
1302
1303 10 memrequested+=(100000);
1304 10 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1305
1306
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((trashbuf=(byte*)malloc(100000))==NULL)
1307 return 0;
1308
1309 10 Z_message("OK\n"); // Allocating trash buffer...
1310
1311 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1312 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1313 // fixed by ensuring there's actually itemdata there.
1314 // If you change this, be sure to update del_qst_buffers, too.
1315
1316 10 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1317 10 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1318
1319
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1320 return 0;
1321
1322 10 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1323 10 itemsbuf++;
1324 10 Z_message("OK\n"); // Allocating item buffer...
1325
1326 10 memrequested+=(sizeof(wpndata)*MAXWPNS);
1327 10 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1328
1329
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1330 return 0;
1331
1332 10 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1333 10 Z_message("OK\n"); // Allocating weapon buffer...
1334
1335 10 memrequested+=(sizeof(guydata)*MAXGUYS);
1336 10 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1337
1338
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1339 return 0;
1340
1341 10 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1342 10 Z_message("OK\n"); // Allocating guy buffer...
1343
1344 10 memrequested+=(sizeof(comboclass)*cMAX);
1345 10 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1346
1347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1348 return 0;
1349
1350 10 Z_message("OK\n"); // Allocating combo class buffer...
1351
1352 10 return 1;
1353 10 }
1354
1355
1356 10 void free_newtilebuf()
1357 {
1358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(newtilebuf)
1359 {
1360 for(int32_t i=0; i<NEWMAXTILES; i++)
1361 if(newtilebuf[i].data)
1362 free(newtilebuf[i].data);
1363
1364 free(newtilebuf);
1365 newtilebuf = 0;
1366 }
1367 10 }
1368
1369 void free_grabtilebuf()
1370 {
1371 if(is_zquest())
1372 {
1373 if(grabtilebuf)
1374 {
1375 for(int32_t i=0; i<NEWMAXTILES; i++)
1376 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1377
1378 free(grabtilebuf);
1379 grabtilebuf = 0;
1380 }
1381 }
1382 }
1383
1384 void del_qst_buffers()
1385 {
1386 al_trace("Cleaning maps. \n");
1387
1388 if(ZCMaps) free(ZCMaps);
1389
1390 if(MsgStrings) delete[] MsgStrings;
1391
1392 if(DoorComboSets) free(DoorComboSets);
1393
1394 if(DMaps) free(DMaps);
1395
1396 if(combobuf) free(combobuf);
1397
1398 if(colordata) free(colordata);
1399
1400 al_trace("Cleaning tile buffers. \n");
1401 free_newtilebuf();
1402 free_grabtilebuf();
1403
1404 al_trace("Cleaning misc. \n");
1405
1406 if(trashbuf) free(trashbuf);
1407
1408 // See get_qst_buffers
1409 if(itemsbuf)
1410 {
1411 itemsbuf--;
1412 free(itemsbuf);
1413 }
1414
1415 if(wpnsbuf) free(wpnsbuf);
1416
1417 if(guysbuf) free(guysbuf);
1418
1419 if(combo_class_buf) free(combo_class_buf);
1420 }
1421
1422 bool init_palnames()
1423 {
1424 // if(palnames==NULL)
1425 // return false;
1426
1427 for(int32_t x=0; x<MAXLEVELS; x++)
1428 {
1429 switch(x)
1430 {
1431 case 0:
1432 sprintf(palnames[x],"Overworld");
1433 break;
1434
1435 case 10:
1436 sprintf(palnames[x],"Caves");
1437 break;
1438
1439 case 11:
1440 sprintf(palnames[x],"Passageways");
1441 break;
1442
1443 default:
1444 sprintf(palnames[x],"%c",0);
1445 break;
1446 }
1447 }
1448
1449 return true;
1450 }
1451
1452 4536 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1453 {
1454 void *p;
1455
1456
1/2
✓ Branch 0 taken 4536 times.
✗ Branch 1 not taken.
4536 p = _AL_MALLOC(MAX(size, alloc_size));
1457
1458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4536 times.
4536 if(!p)
1459 {
1460 return NULL;
1461 }
1462
1463
1/2
✓ Branch 0 taken 4536 times.
✗ Branch 1 not taken.
4536 if(!pfread(p,size,f,keepdata))
1464 {
1465 _AL_FREE(p);
1466 return NULL;
1467 }
1468
1469
1/2
✓ Branch 0 taken 4536 times.
✗ Branch 1 not taken.
4536 if(pack_ferror(f))
1470 {
1471 _AL_FREE(p);
1472 return NULL;
1473 }
1474
1475 4536 return p;
1476 4536 }
1477
1478 /* read_midi:
1479 * Reads MIDI data from a datafile (this is not the same thing as the
1480 * standard midi file format).
1481 */
1482
1483 373 static MIDI *read_midi(PACKFILE *f, bool)
1484 {
1485 MIDI *m;
1486 int32_t c;
1487 373 int16_t divisions=0;
1488 373 int32_t len=0;
1489
1490 373 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1491
1492
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(!m)
1493 {
1494 return NULL;
1495 }
1496
1497
2/2
✓ Branch 0 taken 11936 times.
✓ Branch 1 taken 373 times.
12309 for(c=0; c<MIDI_TRACKS; c++)
1498 {
1499 11936 m->track[c].len = 0;
1500 11936 m->track[c].data = NULL;
1501 11936 }
1502
1503 373 p_mgetw(&divisions,f,true);
1504 373 m->divisions=divisions;
1505
1506
2/2
✓ Branch 0 taken 11936 times.
✓ Branch 1 taken 373 times.
12309 for(c=0; c<MIDI_TRACKS; c++)
1507 {
1508 11936 p_mgetl(&len,f,true);
1509 11936 m->track[c].len=len;
1510
1511
2/2
✓ Branch 0 taken 7400 times.
✓ Branch 1 taken 4536 times.
11936 if(m->track[c].len > 0)
1512 {
1513 4536 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1514
1515
1/2
✓ Branch 0 taken 4536 times.
✗ Branch 1 not taken.
4536 if(!m->track[c].data)
1516 {
1517 destroy_midi(m);
1518 return NULL;
1519 }
1520 4536 }
1521 11936 }
1522
1523 LOCK_DATA(m, sizeof(MIDI));
1524
1525
2/2
✓ Branch 0 taken 11936 times.
✓ Branch 1 taken 373 times.
12309 for(c=0; c<MIDI_TRACKS; c++)
1526 {
1527
2/2
✓ Branch 0 taken 4536 times.
✓ Branch 1 taken 7400 times.
11936 if(m->track[c].data)
1528 {
1529 LOCK_DATA(m->track[c].data, m->track[c].len);
1530 4536 }
1531 11936 }
1532
1533 373 return m;
1534 373 }
1535
1536 void clear_combo(int32_t i)
1537 {
1538 combobuf[i].clear();
1539 }
1540
1541 void clear_combos()
1542 {
1543 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1544 clear_combo(tmpcounter);
1545 }
1546
1547 void pack_combos()
1548 {
1549 int32_t di = 0;
1550
1551 for(int32_t si=0; si<1024; si+=2)
1552 combobuf[di++] = combobuf[si];
1553
1554 for(; di<1024; di++)
1555 clear_combo(di);
1556 }
1557
1558 25 void reset_tunes(zctune *tune)
1559 {
1560
2/2
✓ Branch 0 taken 6300 times.
✓ Branch 1 taken 25 times.
6325 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1561 {
1562 6300 tune[i].reset();
1563 6300 }
1564 25 }
1565
1566
1567 /*void reset_midi(zcmidi_ *m)
1568 {
1569 m->title[0]=0;
1570 m->loop=1;
1571 m->volume=144;
1572 m->start=0;
1573 m->loop_start=-1;
1574 m->loop_end=-1;
1575 if(m->midi)
1576 {
1577 destroy_midi(m->midi);
1578 }
1579 m->midi=NULL;
1580 }
1581
1582
1583 void reset_midis(zcmidi_ *m)
1584 {
1585 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1586 {
1587 reset_midi(m+i);
1588 }
1589 }
1590 */
1591
1592 void reset_scr(int32_t scr)
1593 {
1594 /*
1595 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1596 for(unsigned i=0; i<sizeof(mapscr); i++)
1597 *(di++) = 0;
1598 TheMaps[scr].valid=mVERSION;
1599 */
1600
1601 TheMaps[scr].zero_memory();
1602 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1603
1604 for(int32_t i=0; i<6; i++)
1605 {
1606 //these will be uncommented later
1607 //TheMaps[scr].layerxsize[i]=16;
1608 //TheMaps[scr].layerysize[i]=11;
1609 TheMaps[scr].layeropacity[i]=255;
1610 }
1611
1612 TheMaps[scr].valid=mVERSION;
1613
1614 }
1615
1616 /* For reference:
1617
1618 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1619 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1620 */
1621
1622 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1623 {
1624 for(int32_t i=0; i<9; i++)
1625 {
1626 for(int32_t j=0; j<6; j++)
1627 {
1628 if(j<4)
1629 {
1630 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1631 {
1632 return false;
1633 }
1634
1635 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1636 {
1637 return false;
1638 }
1639
1640 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1641 {
1642 return false;
1643 }
1644
1645 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1646 {
1647 return false;
1648 }
1649 }
1650
1651 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1652 {
1653 return false;
1654 }
1655
1656 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1657 {
1658 return false;
1659 }
1660
1661 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1662 {
1663 return false;
1664 }
1665
1666 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1667 {
1668 return false;
1669 }
1670 }
1671
1672 if(i<2)
1673 {
1674 if(a.flags[i]!=b.flags[i])
1675 {
1676 return false;
1677 }
1678
1679 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1680 {
1681 return false;
1682 }
1683
1684 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1685 {
1686 return false;
1687 }
1688
1689 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1690 {
1691 return false;
1692 }
1693
1694 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1695 {
1696 return false;
1697 }
1698 }
1699
1700 if(i<3)
1701 {
1702 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1703 {
1704 return false;
1705 }
1706
1707 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1708 {
1709 return false;
1710 }
1711
1712 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1713 {
1714 return false;
1715 }
1716
1717 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1718 {
1719 return false;
1720 }
1721 }
1722
1723 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1724 {
1725 return false;
1726 }
1727
1728 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1729 {
1730 return false;
1731 }
1732 }
1733
1734 return true;
1735 }
1736
1737 int32_t doortranslations_u[9][4]=
1738 {
1739 {37,38,53,54},
1740 {37,38,39,40},
1741 {37,38,55,56},
1742 {37,38,39,40},
1743 {37,38,53,54},
1744 {37,38,53,54},
1745 {37,38,53,54},
1746 {7,8,23,24},
1747 {7,8,41,42}
1748 };
1749
1750 int32_t doortranslations_d[9][4]=
1751 {
1752 {117,118,133,134},
1753 {135,136,133,134},
1754 {119,120,133,134},
1755 {135,136,133,134},
1756 {117,118,133,134},
1757 {117,118,133,134},
1758 {117,118,133,134},
1759 {151,152,167,168},
1760 {137,138,167,168},
1761 };
1762
1763 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1764 int32_t doortranslations_l[9][6]=
1765 {
1766 {66,67,82,83,98,99},
1767 {66,68,82,84,98,100},
1768 {66,69,82,85,98,101},
1769 {66,68,82,84,98,100},
1770 {66,67,82,83,98,99},
1771 {66,67,82,83,98,99},
1772 {66,67,82,83,98,99},
1773 {64,65,80,81,96,97},
1774 {64,65,80,114,96,97},
1775 };
1776
1777 int32_t doortranslations_r[9][6]=
1778 {
1779
1780 {76,77,92,93,108,109},
1781 {75,77,91,93,107,109},
1782 {74,77,90,93,106,109},
1783 {75,77,91,93,107,109},
1784 {76,77,92,93,108,109},
1785 {76,77,92,93,108,109},
1786 {76,77,92,93,108,109},
1787 {78,79,94,95,110,111},
1788 {78,79,125,95,110,111},
1789 };
1790
1791 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1792 {
1793 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1794 }
1795
1796 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1797 {
1798 //these are here to bypass compiler warnings about unused arguments
1799 map=map;
1800 scr=scr;
1801 pos=pos;
1802
1803 //what does this function do?
1804 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1805 return 2;
1806 }
1807
1808 int32_t MakeDoors(int32_t map, int32_t scr)
1809 {
1810 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1811 {
1812 return 0;
1813 }
1814
1815 DoorComboSet tempdcs;
1816 memset(&tempdcs, 0, sizeof(DoorComboSet));
1817
1818 //up
1819 for(int32_t i=0; i<9; i++)
1820 {
1821 for(int32_t j=0; j<4; j++)
1822 {
1823 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1824 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1825 }
1826 }
1827
1828 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1829 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1830 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1831 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1832 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1833 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1834
1835 //down
1836 for(int32_t i=0; i<9; i++)
1837 {
1838 for(int32_t j=0; j<4; j++)
1839 {
1840 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1841 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1842 }
1843 }
1844
1845 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1846
1847 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1848 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1849 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1850 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1851 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1852
1853 //left
1854 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1855 for(int32_t i=0; i<9; i++)
1856 {
1857 for(int32_t j=0; j<6; j++)
1858 {
1859 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1860 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1861 }
1862 }
1863
1864 for(int32_t j=0; j>6; j++)
1865 {
1866 if((j!=2)&&(j!=3))
1867 {
1868 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1869 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1870 }
1871 }
1872
1873 tempdcs.bombdoorcombo_l[0]=0;
1874 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1875 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1876 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1877 tempdcs.bombdoorcombo_l[2]=0;
1878 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1879 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1880 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1881
1882 //right
1883 for(int32_t i=0; i<9; i++)
1884 {
1885 for(int32_t j=0; j<6; j++)
1886 {
1887 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1888 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1889 }
1890 }
1891
1892 for(int32_t j=0; j>6; j++)
1893 {
1894 if((j!=2)&&(j!=3))
1895 {
1896 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1897 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1898 }
1899 }
1900
1901 tempdcs.bombdoorcombo_r[0]=0;
1902 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1903 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1904 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1905 tempdcs.bombdoorcombo_r[2]=0;
1906 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1907 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1908 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1909
1910 int32_t k;
1911
1912 for(k=0; k<door_combo_set_count; k++)
1913 {
1914 if(DoorComboSets[k]==tempdcs)
1915 {
1916 break;
1917 }
1918 }
1919
1920 if(k==door_combo_set_count)
1921 {
1922 DoorComboSets[k]=tempdcs;
1923 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1924 ++door_combo_set_count;
1925 }
1926
1927 return k;
1928 /*
1929 doorcombo_u[9][4];
1930 doorcset_u[9][4];
1931 doorcombo_d[9][4];
1932 doorcset_d[9][4];
1933 doorcombo_l[9][6];
1934 doorcset_l[9][6];
1935 doorcombo_r[9][6];
1936 doorcset_r[9][6];
1937 bombdoorcombo_u[2];
1938 bombdoorcset_u[2];
1939 bombdoorcombo_d[2];
1940 bombdoorcset_d[2];
1941 bombdoorcombo_l[3];
1942 bombdoorcset_l[3];
1943 bombdoorcombo_r[3];
1944 bombdoorcset_r[3];
1945 walkthroughcombo[4];
1946 walkthroughcset[4];
1947 */
1948 }
1949
1950 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1951 {
1952 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1953 }
1954
1955 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1956 {
1957
1958 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1959 }
1960
1961 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1962 {
1963 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1964 }
1965
1966
1967 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1968 {
1969 char temp_pwd[30];
1970 memset(temp_pwd,0,30);
1971
1972 if(pwdkey!=0)
1973 {
1974 memcpy(temp_pwd,encrypted_pwd,30);
1975 temp_pwd[29]=0;
1976
1977 for(int32_t i=0; i<30; i++)
1978 {
1979 temp_pwd[i] -= pwdkey;
1980 int32_t t=pwdkey>>15;
1981 pwdkey = (pwdkey<<1)+t;
1982 }
1983 }
1984
1985 memcpy(pwd,temp_pwd,30);
1986 }
1987
1988
1989
1990 bool check_questpwd(zquestheader *Header, char *pwd)
1991 {
1992 #if DEVLEVEL > 3
1993 return true;
1994 #endif
1995
1996 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
1997 cvs_MD5Context ctx;
1998 uint8_t md5sum[16];
1999
2000 cvs_MD5Init(&ctx);
2001 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2002 cvs_MD5Final(md5sum, &ctx);
2003
2004 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2005
2006 }
2007
2008 25 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2009 {
2010 25 zprint2("\n");
2011 25 zprint2("[ZQUEST CREATOR METADATA]\n");
2012
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(qst_num < moduledata.max_quest_files)
2013 zprint2("Loading module quest %d\n", qst_num+1);
2014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(path) zprint2("Loading '%s'\n", path);
2015
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if ( tempheader.new_version_id_main > 0 )
2016 {
2017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tempheader.new_version_id_fourth > 0)
2018 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2019 tempheader.new_version_id_main,tempheader.new_version_id_second,
2020 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2021 25 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2022 25 tempheader.new_version_id_main,tempheader.new_version_id_second,
2023 25 tempheader.new_version_id_third);
2024 25 }
2025 else
2026 {
2027 switch ( tempheader.zelda_version )
2028 {
2029 case 0x255:
2030 {
2031 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2032 break;
2033 }
2034 case 0x254:
2035 {
2036 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2037 break;
2038 }
2039 case 0x250:
2040 {
2041 switch(tempheader.build)
2042 {
2043 case 19:
2044 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2045 case 20:
2046 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2047 case 21:
2048 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2049 case 22:
2050 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2051 case 23:
2052 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2053 case 24:
2054 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2055 case 25:
2056 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2057 case 26:
2058 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2059 case 27:
2060 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2061 case 28:
2062 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2063 case 29:
2064 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2065 case 30:
2066 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2067 case 31:
2068 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2069 case 32:
2070 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2071 case 33:
2072 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2073 default:
2074 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2075
2076 }
2077 break;
2078 }
2079
2080 case 0x211:
2081 {
2082 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2083 }
2084 case 0x210:
2085 {
2086 zprint2("Last saved in ZQuest Version: 2.10.x");
2087 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2088 break;
2089 }
2090 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2091 case 0x193:
2092 {
2093 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2094 }
2095 case 0x192:
2096 {
2097 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2098 }
2099 case 0x190:
2100 {
2101 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2102 }
2103 case 0x184:
2104 {
2105 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2106 }
2107 case 0x183:
2108 {
2109 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2110 }
2111 case 0x180:
2112 {
2113 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2114 }
2115 default:
2116 {
2117 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2118 }
2119 */
2120 }
2121 }
2122
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
25 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2123 1 zprint2("%s\n", tempheader.getAlphaVerStr());
2124 24 else zprint2("\n");
2125
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2126
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2127
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2128
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2130
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2131 25 zprint2("\n");
2132 25 }
2133
2134 35 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2135 {
2136 int32_t dummy;
2137 zquestheader tempheader;
2138 35 memcpy(&tempheader, Header, sizeof(tempheader));
2139 char dummybuf[80];
2140 byte temp_map_count;
2141 byte temp_midi_flags[MIDIFLAGS_SIZE];
2142 word version;
2143 char temp_pwd[30], temp_pwd2[30];
2144 int16_t temp_pwdkey;
2145 cvs_MD5Context ctx;
2146 35 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2147 35 memset(&tempheader, 0, sizeof(tempheader));
2148 35 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2149
2150
2151
2152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2153 {
2154 Z_message("Unable to read header string\n");
2155 return qe_invalid;
2156 }
2157
2158 // check header
2159
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2160 {
2161 if(strcmp(tempheader.id_str,QH_IDSTR))
2162 {
2163 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2164 return qe_invalid;
2165 }
2166 }
2167
2168 35 int32_t templatepath_len=0;
2169
2170 35 tempheader.external_zinfo = false;
2171 35 read_zinfo = false;
2172
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2173 {
2174 byte padding;
2175
2176 if(!p_getc(&padding,f,true))
2177 {
2178 return qe_invalid;
2179 }
2180
2181 if(!p_igetw(&tempheader.zelda_version,f,true))
2182 {
2183 return qe_invalid;
2184 }
2185
2186 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2187
2188 if(tempheader.zelda_version > ZELDA_VERSION)
2189 {
2190 return qe_version;
2191 }
2192
2193 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2194
2195 if(strcmp(tempheader.id_str,QH_IDSTR))
2196 {
2197 return qe_invalid;
2198 }
2199
2200 if(bad_version(tempheader.zelda_version))
2201 {
2202 return qe_obsolete;
2203 }
2204
2205 if(!p_igetw(&tempheader.internal,f,true))
2206 {
2207 return qe_invalid;
2208 }
2209
2210 if(!p_getc(&tempheader.quest_number,f,true))
2211 {
2212 return qe_invalid;
2213 }
2214
2215 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2216
2217 if(!pfread(&quest_rules[0],2,f,true))
2218 {
2219 return qe_invalid;
2220 }
2221
2222 if(!p_getc(&temp_map_count,f,true))
2223 {
2224 return qe_invalid;
2225 }
2226
2227 FFCore.quest_format[qMapCount] = temp_map_count;
2228
2229 if(!p_getc(&tempheader.old_str_count,f,true))
2230 {
2231 return qe_invalid;
2232 }
2233
2234 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2235 {
2236 return qe_invalid;
2237 }
2238
2239 if(!pfread(temp_midi_flags,4,f,true))
2240 {
2241 return qe_invalid;
2242 }
2243
2244 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2245 {
2246 return qe_invalid;
2247 }
2248
2249 if(!pfread(dummybuf,14,f,true))
2250 {
2251 return qe_invalid;
2252 }
2253
2254 if(!pfread(&quest_rules[2],2,f,true))
2255 {
2256 return qe_invalid;
2257 }
2258
2259 if(!p_getc(&dummybuf,f,true))
2260 {
2261 return qe_invalid;
2262 }
2263
2264 if(!pfread(tempheader.version,sizeof(tempheader.version),f,true))
2265 {
2266 return qe_invalid;
2267 }
2268
2269 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2270 {
2271 return qe_invalid;
2272 }
2273
2274 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2275 {
2276 return qe_invalid;
2277 }
2278
2279 if(!p_getc(&padding,f,true))
2280 {
2281 return qe_invalid;
2282 }
2283
2284 if(!p_igetw(&temp_pwdkey,f,true))
2285 {
2286 return qe_invalid;
2287 }
2288
2289 if(!pfread(temp_pwd,30,f,true))
2290 {
2291 return qe_invalid;
2292 }
2293
2294 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2295 cvs_MD5Init(&ctx);
2296 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2297 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2298
2299 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2300 {
2301 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2302 // Not anymore...
2303 memset(tempheader.minver,0,9);
2304 tempheader.build=0;
2305 tempheader.use_keyfile=0;
2306 memset(tempheader.old_foo, 0, 9);
2307 }
2308 else
2309 {
2310 if(!pfread(tempheader.minver,sizeof(tempheader.minver),f,true))
2311 {
2312 return qe_invalid;
2313 }
2314
2315 if(!p_getc(&tempheader.build,f,true))
2316 {
2317 return qe_invalid;
2318 }
2319
2320 FFCore.quest_format[vBuild] = tempheader.build;
2321
2322 if(!p_getc(&tempheader.use_keyfile,f,true))
2323 {
2324 return qe_invalid;
2325 }
2326
2327 if(!pfread(dummybuf,9,f,true))
2328 {
2329 return qe_invalid;
2330 }
2331 } // starting at minver
2332
2333 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2334 {
2335 memset(&quest_rules[4],0,16); // word rules3..rules10
2336 }
2337 else
2338 {
2339 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2340 {
2341 return qe_invalid; // starting at rules3
2342 }
2343
2344 if(tempheader.zelda_version <= 0x190)
2345 {
2346 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2347 }
2348 }
2349
2350 if((tempheader.zelda_version < 0x192)||
2351 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2352 {
2353 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2354 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2355 }
2356
2357 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2358 {
2359 byte *mf=temp_midi_flags;
2360
2361 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2362 {
2363 mf=(byte*)dummybuf;
2364 }
2365
2366 if(!pfread(mf,32,f,true)) // read new header additions
2367 {
2368 return qe_invalid; // starting at foo2
2369 }
2370
2371 if(!pfread(dummybuf,18,f,true)) // read new header additions
2372 {
2373 return qe_invalid; // starting at foo2
2374 }
2375 }
2376
2377 if((tempheader.zelda_version < 0x192)||
2378 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2379 {
2380 memset(tempheader.templatepath,0,2048);
2381 }
2382 else
2383 {
2384 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2385 {
2386 return qe_invalid;
2387 }
2388 }
2389
2390 if((tempheader.zelda_version < 0x192)||
2391 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2392 {
2393 tempheader.use_keyfile=0;
2394 }
2395 }
2396 else
2397 {
2398 //section id
2399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!p_mgetl(&dummy,f,true))
2400 {
2401 return qe_invalid;
2402 }
2403
2404 //section version info
2405
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&version,f,true))
2406 {
2407 return qe_invalid;
2408 }
2409
2410 35 FFCore.quest_format[vHeader] = version;
2411
2412
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&dummy,f,true))
2413 {
2414 return qe_invalid;
2415 }
2416
2417 //section size
2418
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&dummy,f,true))
2419 {
2420 return qe_invalid;
2421 }
2422
2423 //finally... section data
2424
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&tempheader.zelda_version,f,true))
2425 {
2426 return qe_invalid;
2427 }
2428
2429 35 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2430
2431 //do some quick checking...
2432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(tempheader.zelda_version > ZELDA_VERSION)
2433 {
2434 return qe_version;
2435 }
2436
2437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2438 {
2439 return qe_invalid;
2440 }
2441
2442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(bad_version(tempheader.zelda_version))
2443 {
2444 return qe_obsolete;
2445 }
2446
2447
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.build,f,true))
2448 {
2449 return qe_invalid;
2450 }
2451
2452 35 FFCore.quest_format[vBuild] = tempheader.build;
2453
2454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(version<3)
2455 {
2456 if(!pfread(temp_pwd,30,f,true))
2457 {
2458 return qe_invalid;
2459 }
2460
2461 if(!p_igetw(&temp_pwdkey,f,true))
2462 {
2463 return qe_invalid;
2464 }
2465
2466 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2467 cvs_MD5Init(&ctx);
2468 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2469 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2470 }
2471 else
2472 {
2473
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2474 {
2475 return qe_invalid;
2476 }
2477 }
2478
2479
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&tempheader.internal,f,true))
2480 {
2481 return qe_invalid;
2482 }
2483
2484
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.quest_number,f,true))
2485 {
2486 return qe_invalid;
2487 }
2488
2489 35 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2490
2491
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.version,sizeof(tempheader.version),f,true))
2492 {
2493 return qe_invalid;
2494 }
2495
2496 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2497 //needs to be copied as char[9] or stored as a s.str
2498
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.minver,sizeof(tempheader.minver),f,true))
2499 {
2500 return qe_invalid;
2501 }
2502
2503 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2504 //needs to be copied as char[9] or stored as a s.str
2505
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2506 {
2507 return qe_invalid;
2508 }
2509
2510
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2511 {
2512 return qe_invalid;
2513 }
2514
2515
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.use_keyfile,f,true))
2516 {
2517 return qe_invalid;
2518 }
2519
2520 /*
2521 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2522 {
2523 return qe_invalid;
2524 }
2525 */
2526
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2527 {
2528 return qe_invalid;
2529 }
2530
2531
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(&dummybuf,4,f,true))
2532 {
2533 return qe_invalid;
2534 }
2535
2536
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2537 {
2538 return qe_invalid;
2539 }
2540
2541
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(dummybuf,14,f,true))
2542 {
2543 return qe_invalid;
2544 }
2545
2546 35 templatepath_len=sizeof(tempheader.templatepath);
2547
2548
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(version==1)
2549 {
2550 templatepath_len=280;
2551 }
2552
2553
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2554 {
2555 return qe_invalid;
2556 }
2557
2558
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&temp_map_count,f,true))
2559 {
2560 return qe_invalid;
2561 }
2562
2563
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 24 times.
35 if(version>=4)
2564 {
2565
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2566 {
2567 return qe_invalid;
2568 }
2569
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2570 {
2571 return qe_invalid;
2572 }
2573
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2574 {
2575 return qe_invalid;
2576 }
2577
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2578 {
2579 return qe_invalid;
2580 }
2581
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2582 {
2583 return qe_invalid;
2584 }
2585
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2586 {
2587 return qe_invalid;
2588 }
2589
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2590 {
2591 return qe_invalid;
2592 }
2593
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2594 {
2595 return qe_invalid;
2596 }
2597
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2598 {
2599 return qe_invalid;
2600 }
2601
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2602 {
2603 return qe_invalid;
2604 }
2605
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2606 {
2607 return qe_invalid;
2608 }
2609
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2610 {
2611 return qe_invalid;
2612 }
2613
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2614 {
2615 return qe_invalid;
2616 }
2617
2618
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!pfread(tempheader.new_version_devsig,256,f,true))
2619 {
2620 return qe_invalid;
2621 }
2622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2623 strcpy(tempheader.new_version_devsig, "EmilyV99");
2624
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!pfread(tempheader.new_version_compilername,256,f,true))
2625 {
2626 return qe_invalid;
2627 }
2628
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2629 {
2630 return qe_invalid;
2631 }
2632
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!pfread(tempheader.product_name,1024,f,true))
2633 {
2634 return qe_invalid;
2635 }
2636
2637
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&tempheader.compilerid,f,true))
2638 {
2639 return qe_invalid;
2640 }
2641
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2642 {
2643 return qe_invalid;
2644 }
2645
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2646 {
2647 return qe_invalid;
2648 }
2649
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2650 {
2651 return qe_invalid;
2652 }
2653
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2654 {
2655 return qe_invalid;
2656 }
2657
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&tempheader.developerid,f,true))
2658 {
2659 return qe_invalid;
2660 }
2661
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2662 {
2663 return qe_invalid;
2664 }
2665
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!pfread(tempheader.build_datestamp,256,f,true))
2666 {
2667 return qe_invalid;
2668 }
2669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!pfread(tempheader.build_timestamp,256,f,true))
2670 {
2671 return qe_invalid;
2672 }
2673 11 }
2674 else // <4
2675 {
2676 24 tempheader.new_version_id_main = 0;
2677 24 tempheader.new_version_id_second = 0;
2678 24 tempheader.new_version_id_third = 0;
2679 24 tempheader.new_version_id_fourth = 0;
2680 24 tempheader.new_version_id_alpha = 0;
2681 24 tempheader.new_version_id_beta = 0;
2682 24 tempheader.new_version_id_gamma = 0;
2683 24 tempheader.new_version_id_release = 0;
2684 24 tempheader.new_version_id_date_year = 0;
2685 24 tempheader.new_version_id_date_month = 0;
2686 24 tempheader.new_version_id_date_day = 0;
2687 24 tempheader.new_version_id_date_hour = 0;
2688 24 tempheader.new_version_id_date_minute = 0;
2689
2690 24 memset(tempheader.new_version_devsig, 0, 256);
2691 24 memset(tempheader.new_version_compilername, 0, 256);
2692 24 memset(tempheader.new_version_compilerversion, 0, 256);
2693 24 memset(tempheader.product_name, 0, 1024);
2694 24 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2695
2696 24 tempheader.compilerid = 0;
2697 24 tempheader.compilerversionnumber_first = 0;
2698 24 tempheader.compilerversionnumber_second = 0;
2699 24 tempheader.compilerversionnumber_third = 0;
2700 24 tempheader.compilerversionnumber_fourth = 0;
2701 24 tempheader.developerid = 0;
2702
2703 24 memset(tempheader.made_in_module_name, 0, 1024);
2704 24 memset(tempheader.build_datestamp, 0, 256);
2705 24 memset(tempheader.build_timestamp, 0, 256);
2706 }
2707
2708
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 24 times.
35 if ( version >= 5 )
2709 {
2710
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!pfread(tempheader.build_timezone,6,f,true))
2711 {
2712 return qe_invalid;
2713 }
2714 11 }
2715 else // < 5
2716 {
2717 24 memset(tempheader.build_timezone, 0, 6);
2718 }
2719
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if ( version >= 6 )
2720 {
2721 byte b;
2722
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&b,f,true))
2723 {
2724 return qe_invalid;
2725 }
2726 11 tempheader.external_zinfo = b?true:false;
2727 11 read_zinfo = true;
2728 11 }
2729
2730
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 24 times.
35 if(version >= 7)
2731 {
2732
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2733 {
2734 return qe_invalid;
2735 }
2736 11 }
2737 else
2738 {
2739 24 tempheader.new_version_is_nightly = false;
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version < 0x255)
2741 {
2742
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
24 switch(tempheader.zelda_version)
2743 {
2744 case 0x254:
2745 tempheader.new_version_id_main = 2;
2746 tempheader.new_version_id_second = 54;
2747 break;
2748 case 0x250:
2749
5/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 8 times.
✗ Branch 15 not taken.
24 switch(tempheader.build)
2750 {
2751 case 19:
2752 tempheader.new_version_id_main = 2;
2753 tempheader.new_version_id_second = 50;
2754 tempheader.new_version_id_gamma = 1;
2755 break;
2756 case 20:
2757 tempheader.new_version_id_main = 2;
2758 tempheader.new_version_id_second = 50;
2759 tempheader.new_version_id_gamma = 2;
2760 break;
2761 case 21:
2762 tempheader.new_version_id_main = 2;
2763 tempheader.new_version_id_second = 50;
2764 tempheader.new_version_id_gamma = 3;
2765 break;
2766 case 22:
2767 tempheader.new_version_id_main = 2;
2768 tempheader.new_version_id_second = 50;
2769 tempheader.new_version_id_gamma = 4;
2770 break;
2771 case 23:
2772 tempheader.new_version_id_main = 2;
2773 tempheader.new_version_id_second = 50;
2774 tempheader.new_version_id_gamma = 5;
2775 break;
2776 case 24:
2777 2 tempheader.new_version_id_main = 2;
2778 2 tempheader.new_version_id_second = 50;
2779 2 tempheader.new_version_id_release = -1;
2780 2 break;
2781 case 25:
2782 tempheader.new_version_id_main = 2;
2783 tempheader.new_version_id_second = 50;
2784 tempheader.new_version_id_third = 1;
2785 tempheader.new_version_id_gamma = 1;
2786 break;
2787 case 26:
2788 tempheader.new_version_id_main = 2;
2789 tempheader.new_version_id_second = 50;
2790 tempheader.new_version_id_third = 1;
2791 tempheader.new_version_id_gamma = 2;
2792 break;
2793 case 27:
2794 tempheader.new_version_id_main = 2;
2795 tempheader.new_version_id_second = 50;
2796 tempheader.new_version_id_third = 1;
2797 tempheader.new_version_id_gamma = 3;
2798 break;
2799 case 28:
2800 4 tempheader.new_version_id_main = 2;
2801 4 tempheader.new_version_id_second = 50;
2802 4 tempheader.new_version_id_third = 1;
2803 4 tempheader.new_version_id_release = -1;
2804 4 break;
2805 case 29:
2806 7 tempheader.new_version_id_main = 2;
2807 7 tempheader.new_version_id_second = 50;
2808 7 tempheader.new_version_id_third = 2;
2809 7 tempheader.new_version_id_release = -1;
2810 7 break;
2811 case 30:
2812 tempheader.new_version_id_main = 2;
2813 tempheader.new_version_id_second = 50;
2814 tempheader.new_version_id_third = 3;
2815 tempheader.new_version_id_gamma = 1;
2816 break;
2817 case 31:
2818 3 tempheader.new_version_id_main = 2;
2819 3 tempheader.new_version_id_second = 53;
2820 3 tempheader.new_version_id_gamma = -1;
2821 3 break;
2822 case 32:
2823 8 tempheader.new_version_id_main = 2;
2824 8 tempheader.new_version_id_second = 53;
2825 8 tempheader.new_version_id_release = -1;
2826 8 break;
2827 case 33:
2828 tempheader.new_version_id_main = 2;
2829 tempheader.new_version_id_second = 53;
2830 tempheader.new_version_id_third = 1;
2831 break;
2832 }
2833 24 break;
2834
2835 case 0x211:
2836 tempheader.new_version_id_main = 2;
2837 tempheader.new_version_id_second = 11;
2838 tempheader.new_version_id_beta = tempheader.build;
2839 break;
2840 case 0x210:
2841 tempheader.new_version_id_main = 2;
2842 tempheader.new_version_id_second = 10;
2843 tempheader.new_version_id_beta = tempheader.build;
2844 break;
2845 }
2846 24 }
2847 }
2848
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(printmetadata || __isZQuest)
2849 {
2850 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2851 }
2852 }
2853
2854 //{ Version Warning
2855 35 int32_t vercmp = tempheader.compareVer();
2856 35 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2857 35 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2858
4/6
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
46 if(vercmp > 0 || (!vercmp &&
2859
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 (astatecmp > 0 || (!astatecmp &&
2860 11 avercmp > 0))))
2861 {
2862 bool r = true;
2863 if(loadquest_report)
2864 {
2865 enter_sys_pal();
2866 AlertDialog("Quest saved in newer version",
2867 "This quest was last saved in a newer version of ZQuest."
2868 " Attempting to load this quest may not work correctly; to"
2869 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2870 "\n\nWould you like to continue loading anyway? (Not recommended)",
2871 [&](bool ret,bool)
2872 {
2873 r = ret;
2874 }).show();
2875 exit_sys_pal();
2876 }
2877 if(!r)
2878 return qe_silenterr;
2879 }
2880
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(tempheader.compareDate() > 0)
2881 {
2882 bool r = true;
2883 if(loadquest_report)
2884 {
2885 enter_sys_pal();
2886 AlertDialog("Quest saved in newer build",
2887 "This quest was last saved in a newer build of ZQuest, and may have"
2888 " issues loading in this build."
2889 "\n\nWould you like to continue loading anyway?",
2890 [&](bool ret,bool)
2891 {
2892 r = ret;
2893 }).show();
2894 exit_sys_pal();
2895 }
2896 if(!r)
2897 return qe_silenterr;
2898 }
2899 //}
2900
2901 35 read_ext_zinfo = tempheader.external_zinfo;
2902
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(keepdata==true)
2904 {
2905 35 memcpy(Header, &tempheader, sizeof(tempheader));
2906 35 map_count=temp_map_count;
2907 35 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2908 35 }
2909
2910 35 return 0;
2911 35 }
2912
2913 25 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
2914 {
2915 int32_t dummy;
2916 zquestheader tempheader;
2917 25 word s_version=0;
2918 25 dword compatrule_version=0;
2919
2920 25 memcpy(&tempheader, Header, sizeof(tempheader));
2921
2922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tempheader.zelda_version >= 0x193)
2923 {
2924 //section version info
2925
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
2926 {
2927 return qe_invalid;
2928 }
2929
2930 25 FFCore.quest_format[vRules] = s_version;
2931
2932
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&dummy,f,true))
2933 {
2934 return qe_invalid;
2935 }
2936
2937
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version > 16)
2938 {
2939
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&compatrule_version,f,true))
2940 {
2941 return qe_invalid;
2942 }
2943 1 }
2944 25 FFCore.quest_format[vCompatRule] = compatrule_version;
2945
2946 //section size
2947
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
2948 {
2949 return qe_invalid;
2950 }
2951
2952
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if ( s_version < 15 )
2953 {
2954 //finally... section data
2955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
2956 {
2957 return qe_invalid;
2958 }
2959 24 }
2960 else
2961 {
2962
2963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
2964 {
2965 return qe_invalid;
2966 }
2967
2968 }
2969 25 }
2970
2971 //al_trace("Rules version %d\n", s_version);
2972 //{ bunch of compat stuff
2973 25 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2974
2975
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<2)
2976 {
2977 set_bit(quest_rules,14,0);
2978 set_bit(quest_rules,27,0);
2979 set_bit(quest_rules,28,0);
2980 set_bit(quest_rules,29,0);
2981 set_bit(quest_rules,30,0);
2982 set_bit(quest_rules,32,0);
2983 set_bit(quest_rules,36,0);
2984 set_bit(quest_rules,49,0);
2985 set_bit(quest_rules,50,0);
2986 set_bit(quest_rules,51,0);
2987 set_bit(quest_rules,68,0);
2988 set_bit(quest_rules,75,0);
2989 set_bit(quest_rules,76,0);
2990 set_bit(quest_rules,98,0);
2991 set_bit(quest_rules,110,0);
2992 set_bit(quest_rules,113,0);
2993 set_bit(quest_rules,116,0);
2994 set_bit(quest_rules,102,0);
2995 set_bit(quest_rules,132,0);
2996 }
2997
2998 //Now, do any updates...
2999
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3000 {
3001 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3002 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3003 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3004 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3005 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3006 }
3007
3008
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3009 {
3010 set_bit(quest_rules,qr_WALLFLIERS,1);
3011 }
3012
3013
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3014 {
3015 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3016 }
3017
3018
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3019 {
3020 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3021 }
3022
3023
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(tempheader.zelda_version <= 0x210)
3024 {
3025 set_bit(quest_rules,qr_ARROWCLIP,1);
3026 }
3027
3028
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(tempheader.zelda_version == 0x210)
3029 {
3030 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3031 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3032 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3033 }
3034
3035
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(tempheader.zelda_version <= 0x210)
3036 {
3037 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3038 set_bit(quest_rules,qr_210_WARPRETURN,1);
3039 }
3040
3041 //might not be correct
3042
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(tempheader.zelda_version < 0x210)
3043 {
3044 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3045 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3046 }
3047
3048
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(tempheader.zelda_version < 0x211)
3049 {
3050 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3051 }
3052
3053
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3054 {
3055 set_bit(quest_rules, qr_192b163_WARP,1);
3056 }
3057
3058
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(tempheader.zelda_version == 0x210)
3059 {
3060 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3061 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3062 }
3063
3064
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3065 {
3066 set_bit(quest_rules, qr_OLDPICKUP,1);
3067 }
3068
3069
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3070 {
3071 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3072 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3073 }
3074
3075
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3076 {
3077 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3078 }
3079
3080
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 2 times.
25 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3081 {
3082 2 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3083 2 }
3084
3085
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
25 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3086 {
3087 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3088 }
3089
3090
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
25 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3091 {
3092 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3093 }
3094
3095
5/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 22 times.
25 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3096 {
3097 2 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3098 2 }
3099
3100
5/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 22 times.
25 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3101 {
3102 2 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3103 2 }
3104
3105 //Bombchu fix.
3106
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(tempheader.zelda_version == 0x250)
3107 {
3108
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
24 if ( tempheader.build == 24 ) //2.50.0
3109 {
3110 2 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3111 2 }
3112
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
24 if ( tempheader.build == 28 ) //2.50.1
3113 {
3114 4 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3115 4 }
3116
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 7 times.
24 if ( tempheader.build == 29 ) //2.50.2
3117 {
3118 7 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3119 7 }
3120
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if ( tempheader.build == 30 ) //2.50.3RC1
3121 {
3122 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3123 }
3124 24 }
3125
3126
5/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 18 times.
25 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3127 {
3128 // qr_OFFSETEWPNCOLLISIONFIX
3129 // All 'official' quests need this disabled.
3130 // All 2.10 and lower quests need this enabled to preseve compatability.
3131 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3132
3133 //~Gleeok
3134 6 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3135
3136 // Broke in build 695
3137
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3138 6 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3139 6 }
3140
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (tempheader.zelda_version <= 0x190)
3141 {
3142 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3143 }
3144
6/10
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
25 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3145 {
3146 24 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3147 24 }
3148
3149
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3150 {
3151 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3152 }
3153
3154
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3155 {
3156 24 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3157 24 }
3158
3159
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if ( tempheader.zelda_version < 0x250 )
3160 {
3161 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3162 }
3163
3164
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version < 3)
3165 {
3166 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3167 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3168 }
3169
3170
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<4)
3171 {
3172 set_bit(quest_rules,10,0);
3173 }
3174
3175
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<5)
3176 {
3177 set_bit(quest_rules,27,0);
3178 }
3179
3180
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<6)
3181 {
3182 set_bit(quest_rules,46,0);
3183 }
3184
3185
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<7) // January 2008
3186 {
3187 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3188 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3189 }
3190
3191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version<8)
3192 {
3193 set_bit(quest_rules, 12, 0);
3194 }
3195 else
3196 {
3197 25 set_bit(deprecated_rules, 12, 0);
3198 }
3199
3200
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<9) // October 2008
3201 {
3202 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3203 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3204 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3205 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3206 }
3207
3208
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<10) // December 2008
3209 {
3210 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3211 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3212 }
3213
3214
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<11) // April 2009
3215 {
3216 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3217 }
3218
3219
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<12) // December 2009
3220 {
3221 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3222 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3223 }
3224
3225 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3226
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version < 13)
3227 {
3228 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3229 }
3230
3231 // Not entirely sure this is the best place for this...
3232 //2.50.2 bitmap offset fix
3233 25 memset(extra_rules, 0, EXTRARULES_SIZE);
3234
5/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 18 times.
25 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3235 {
3236 6 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3237 6 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3238 6 }
3239 //required because quest templates also used this bit, although
3240 //it never did anything, before. -Z
3241
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( tempheader.zelda_version == 0x250 )
3242 {
3243
5/6
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 14 times.
24 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3244 {
3245 10 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3246 10 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3247 10 }
3248 24 }
3249
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if ( tempheader.zelda_version == 0x254 )
3250 {
3251 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3252 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3253 }
3254
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
25 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3255 {
3256 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3257 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3258 }
3259 //optimise fast drawing for older versions.
3260
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3261 {
3262 24 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3263 24 }
3264 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3265 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3266 //older quests can set the rule by hand. We need a new qst.dat again.
3267
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3268 {
3269 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3270 }
3271
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3272 {
3273 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3274 }
3275
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3276 {
3277 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3278 }
3279
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( tempheader.zelda_version < 0x254 )
3280 {
3281 24 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3282 24 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3283 24 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3284 24 }
3285
3286 //item scripts continue to run
3287
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3288 {
3289 24 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3290 24 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3291 24 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3292 24 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3293 24 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3294 24 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3295 24 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3296 24 }
3297
3298
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3299 {
3300 24 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3301 24 }
3302
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3303 {
3304 24 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3305 24 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3306 24 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3307 24 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3308 24 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3309 24 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3310 24 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3311 24 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3312
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3313 {
3314 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3315 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3316 //Now they **do**, unless you disable that behaviour.
3317 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3318 //now enable the disable L/R item swap on load.
3319 }
3320
3321 24 }
3322
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3323 {
3324 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3325 24 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3326 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3327 //animations ending earlier than they should.
3328 24 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3329 //Enemies would ignore solidity on the top half of combos
3330 24 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3331 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3332 24 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3333 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3334 24 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3335 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3336 24 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3337 24 }
3338
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( tempheader.zelda_version < 0x255 )
3339 {
3340 24 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3341 24 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3342 24 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3343 24 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3344 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3345 24 }
3346
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3347 {
3348 24 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3349 24 }
3350
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3351 {
3352 24 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3353 24 }
3354
3355
3356
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3357 {
3358 24 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3359 24 }
3360
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3361 {
3362 24 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3363 24 }
3364
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3365 {
3366 24 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3367 24 }
3368
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3369 {
3370 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3371
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3372 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3373 24 }
3374
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3375 {
3376 24 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3377 24 }
3378
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3379 {
3380 24 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3381 24 }
3382
3383
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( tempheader.zelda_version < 0x254 )
3384 {
3385 24 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3386 24 }
3387 //Sideview spikes in 2.50.0
3388
5/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 22 times.
25 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3389 {
3390 2 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3391 2 }
3392 //more 2.50 fixes -Z
3393
5/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 11 times.
25 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3394 {
3395 13 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3396 13 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3397 13 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3398 13 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3399 13 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3400
3401 13 }
3402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3403 {
3404 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3405 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3406 }
3407
3408
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(tempheader.zelda_version < 0x193)
3409 {
3410 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3411 }
3412
3413
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(tempheader.zelda_version < 0x255)
3414 {
3415 24 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3416 24 }
3417
3418
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3419 {
3420 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3421 }
3422
3423
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3424 {
3425 24 set_bit(quest_rules,qr_OLD_F6,1);
3426 24 }
3427
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3428 {
3429 24 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3430 24 }
3431
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3432 {
3433 24 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3434 24 }
3435
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3436 {
3437 24 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3438 24 }
3439 //}
3440
3441
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 1)
3442 {
3443 //Enemies->Secret only affects flag 16-31
3444 24 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3445 24 }
3446
3447
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 2)
3448 {
3449 //Old CSet2 Handling
3450 24 set_bit(quest_rules,qr_OLDCS2,1);
3451 24 }
3452
3453
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 3)
3454 {
3455 //Hardcoded Shadow/Spawn/Death anim frames
3456 24 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3457 24 }
3458
3459
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 4)
3460 {
3461 //Hardcoded Shadow/Spawn/Death anim frames
3462 24 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3463 24 }
3464
3465
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
25 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250)
3466 {
3467 //Hardcoded Shadow/Spawn/Death anim frames
3468 24 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3469 24 }
3470
3471
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 6)
3472 {
3473 //Step->Secret (Temp) only affects flag 16-31
3474 24 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3475 24 }
3476
3477
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 7)
3478 {
3479 //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3480 24 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3481 24 }
3482
3483
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 8)
3484 {
3485 //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3486 24 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3487 24 }
3488
3489
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 9)
3490 {
3491 //Hardcoded BS Patras
3492 24 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3493 //Hardcoded Patra Inner Eye offsets
3494 24 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3495 //Broken 'Big enemy' animation style
3496 24 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3497 //Broken Attribute 31/32
3498 24 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3499 24 }
3500
3501
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 10)
3502 {
3503 //Shared candle use limits
3504 24 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3505 24 }
3506
3507
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 11)
3508 {
3509 //No cross-screen return points
3510 24 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3511 24 }
3512
3513
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 12)
3514 {
3515 //Old fire trail duration
3516 24 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3517 //Old Intro String in Ganon Room Behavior
3518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3519 24 else set_bit(quest_rules,qr_GANONINTRO,1);
3520 24 }
3521
3522
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
25 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255)
3523 {
3524 //ANone doesn't reset to originaltile
3525 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3526 }
3527
3528
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 14)
3529 {
3530 //Old Bridge Combo Behavior
3531 24 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3532 24 }
3533
3534
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 15)
3535 {
3536 //Broken Z3 Animation
3537 24 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3538 24 }
3539
3540
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 16)
3541 {
3542 //Old Enemy Tile Behavior with Animation (None) Enemies
3543 24 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3544 24 }
3545
3546
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 17)
3547 {
3548 //Old Quake/DrawYOffset behavior
3549 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3550 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3551 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3552 24 }
3553
3554
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 18)
3555 {
3556 //Broken DrawScreen Derivative Functions
3557 24 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3558 //Scrolling Cancels Charge
3559 24 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3560 24 }
3561
3562
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 19)
3563 {
3564 //Broken Enemy Item Carrying with Large Enemies
3565 24 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3566 24 }
3567
3568
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 20)
3569 {
3570 24 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3571 24 }
3572
3573
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 21)
3574 {
3575 24 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3576 24 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3577 24 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3578 24 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3579 24 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3580 24 }
3581
3582
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 22)
3583 {
3584 24 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3585 24 }
3586
3587
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 23)
3588 {
3589 24 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3590 24 }
3591
3592
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 24)
3593 {
3594 24 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3595 24 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3596 24 }
3597
3598
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 25)
3599 {
3600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3601 24 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3602 24 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3603 24 }
3604
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 26)
3605 {
3606 24 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3607 24 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3608 24 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3609 24 }
3610
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3611 {
3612
2/2
✓ Branch 0 taken 7224 times.
✓ Branch 1 taken 24 times.
7248 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3613 7224 set_bit(quest_rules,q,0);
3614
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 24 times.
2712 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3615 2688 set_bit(quest_rules,q,0);
3616 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3617 24 }
3618
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 28)
3619 {
3620 24 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3621 24 }
3622
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 29)
3623 {
3624 24 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3625 24 }
3626
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 30)
3627 {
3628 24 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3629 24 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3630 24 }
3631
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 31)
3632 {
3633 24 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3634 24 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3635 24 }
3636
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 32)
3637 {
3638 24 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3639 24 }
3640
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(compatrule_version < 33)
3641 {
3642 24 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3643 24 }
3644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(compatrule_version < 34)
3645 {
3646 25 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3647 25 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3648 25 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3649 25 }
3650
3651 //always set
3652 25 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3653
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if (s_version < 16) set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
3655 {
3656 25 memcpy(Header, &tempheader, sizeof(tempheader));
3657 25 }
3658 25 return 0;
3659 25 }
3660
3661 205989 void init_msgstr(MsgStr *str)
3662 {
3663 205989 str->s = "";
3664 205989 str->s.shrink_to_fit();
3665 205989 str->nextstring=0;
3666 205989 str->tile=0;
3667 205989 str->cset=0;
3668 205989 str->trans=false;
3669 205989 str->font=font_zfont;
3670 205989 str->y=32;
3671 205989 str->sfx=18;
3672 205989 str->listpos=0;
3673 205989 str->x=24;
3674 205989 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3675 205989 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3676 205989 str->hspace=0;
3677 205989 str->vspace=0;
3678 205989 str->stringflags=0;
3679 205989 str->margins[up] = 8;
3680 205989 str->margins[down] = 0;
3681 205989 str->margins[left] = 8;
3682 205989 str->margins[right] = 0;
3683 205989 str->portrait_tile = 0;
3684 205989 str->portrait_cset = 0;
3685 205989 str->portrait_x = 0;
3686 205989 str->portrait_y = 0;
3687 205989 str->portrait_tw = 1;
3688 205989 str->portrait_th = 1;
3689 205989 str->shadow_type = 0;
3690 205989 str->shadow_color = 0;
3691 205989 str->drawlayer = 6;
3692 205989 }
3693
3694 25 void init_msgstrings(int32_t start, int32_t end)
3695 {
3696
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(end <= start || end-start > msg_strings_size)
3697 return;
3698
3699
2/2
✓ Branch 0 taken 204800 times.
✓ Branch 1 taken 25 times.
204825 for(int32_t i=start; i<end; i++)
3700 {
3701 204800 init_msgstr(&MsgStrings[i]);
3702 204800 MsgStrings[i].listpos=i;
3703 204800 }
3704
3705
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(start==0)
3706 {
3707 25 MsgStrings[0].s = "(None)";
3708 25 MsgStrings[0].listpos = 0;
3709 25 }
3710 25 }
3711
3712 25 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3713 {
3714 25 MsgStr tempMsgString;
3715
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 init_msgstr(&tempMsgString);
3716
3717 25 word temp_msg_count=0;
3718 word temp_expansion[16];
3719 25 memset(temp_expansion, 0, 16*sizeof(word));
3720 25 char buf[8193] = {0};
3721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version < 0x193)
3722 {
3723 byte tempbyte;
3724 int32_t strings_to_read=0;
3725 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3726 if((Header->zelda_version < 0x192)||
3727 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3728 {
3729 strings_to_read=128;
3730 temp_msg_count=Header->old_str_count;
3731
3732 // Some sort of string count corruption seems to be common in old quests
3733 if(temp_msg_count>128)
3734 {
3735 temp_msg_count=128;
3736 }
3737 }
3738 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3739 {
3740 strings_to_read=255;
3741 temp_msg_count=Header->old_str_count;
3742 }
3743 else
3744 {
3745 if(!p_igetw(&temp_msg_count,f,true))
3746 {
3747 return qe_invalid;
3748 }
3749
3750 strings_to_read=temp_msg_count;
3751
3752 if(temp_msg_count >= msg_strings_size)
3753 {
3754 Z_message("Reallocating string buffer...\n");
3755
3756 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3757 // return qe_nomem;
3758
3759 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3760 delete[] MsgStrings;
3761 MsgStrings = new MsgStr[MAXMSGS];
3762 msg_strings_size = MAXMSGS;
3763 for(auto q = 0; q < msg_strings_size; ++q)
3764 {
3765 MsgStrings[q].clear();
3766 }
3767 }
3768 }
3769
3770 //reset the message strings
3771 if(keepdata)
3772 {
3773 init_msgstrings(0,msg_strings_size);
3774 }
3775
3776 for(int32_t x=0; x<strings_to_read; x++)
3777 {
3778 init_msgstr(&tempMsgString);
3779
3780 if(!pfread(buf,73,f,true))
3781 {
3782 return qe_invalid;
3783 }
3784
3785 buf[74] = '\0';
3786 tempMsgString.s = buf;
3787
3788 if(!p_getc(&tempbyte,f,true))
3789 {
3790 return qe_invalid;
3791 }
3792
3793 if((Header->zelda_version < 0x192)||
3794 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3795 {
3796 tempMsgString.nextstring=tempbyte?x+1:0;
3797
3798 if(!p_getc(&tempbyte,f,true))
3799 {
3800 return qe_invalid;
3801 }
3802
3803 if(!p_getc(&tempbyte,f,true))
3804 {
3805 return qe_invalid;
3806 }
3807 }
3808 else
3809 {
3810 if(!p_igetw(&tempMsgString.nextstring,f,true))
3811 {
3812 return qe_invalid;
3813 }
3814
3815 if(!pfread(temp_expansion,32,f,true))
3816 {
3817 return qe_invalid;
3818 }
3819 }
3820
3821 if(keepdata==true)
3822 {
3823 MsgStrings[x] = tempMsgString;
3824 }
3825 }
3826 }
3827 else
3828 {
3829 int32_t dummy_int;
3830 word s_version;
3831 word s_cversion;
3832
3833 //section version info
3834
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&s_version,f,true))
3835 {
3836 return qe_invalid;
3837 }
3838
3839 25 FFCore.quest_format[vStrings] = s_version;
3840
3841
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&s_cversion,f,true))
3842 {
3843 return qe_invalid;
3844 }
3845
3846 //al_trace("Strings version %d\n", s_version);
3847 //section size
3848
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetl(&dummy_int,f,true))
3849 {
3850 return qe_invalid;
3851 }
3852
3853 //finally... section data
3854
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_msg_count,f,true))
3855 {
3856 return qe_invalid;
3857 }
3858
3859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(temp_msg_count >= msg_strings_size)
3860 {
3861 Z_message("Reallocating string buffer...\n");
3862
3863 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3864 // return qe_nomem;
3865 delete[] MsgStrings;
3866 MsgStrings = new MsgStr[MAXMSGS];
3867 msg_strings_size = MAXMSGS;
3868 for(auto q = 0; q < msg_strings_size; ++q)
3869 {
3870 MsgStrings[q].clear();
3871 }
3872 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3873 }
3874
3875 //reset the message strings
3876
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(keepdata)
3877 {
3878
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version < 7)
3879
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3880
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 init_msgstrings(0,msg_strings_size);
3881 25 }
3882
3883 25 int32_t string_length=(s_version<2)?73:145;
3884
3885
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 25 times.
1189 for(int32_t i=0; i<temp_msg_count; i++)
3886 {
3887
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 init_msgstr(&tempMsgString);
3888
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1162 times.
1164 if(s_version > 8)
3889 {
3890
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetl(&string_length,f,true))
3891 {
3892 return qe_invalid;
3893 }
3894 2 }
3895
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (string_length > 0)
3896 {
3897
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (!pfread(buf, string_length, f, true))
3898 {
3899 return qe_invalid;
3900 }
3901 1164 }
3902 else
3903 {
3904 buf[0] = 0;
3905 }
3906
3907
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_igetw(&tempMsgString.nextstring,f,true))
3908 {
3909 return qe_invalid;
3910 }
3911
3912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164 times.
1164 if(s_version<2)
3913 {
3914 buf[72] = '\0';
3915 tempMsgString.s = buf;
3916 }
3917 else
3918 {
3919 // June 2008: A bug corrupted the last 4 chars of a string.
3920 // Discard these.
3921
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if(s_version<3)
3922 {
3923 for(int32_t j=140; j<144; j++)
3924 {
3925 buf[j] = '\0';
3926 }
3927 }
3928
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if(string_length > 8192) string_length = 8192;
3929 1164 buf[string_length]='\0'; //Force-terminate
3930
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 tempMsgString.s = buf;
3931
3932
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1162 times.
1164 if ( s_version >= 6 )
3933 {
3934
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetl(&tempMsgString.tile,f,true))
3935 {
3936 return qe_invalid;
3937 }
3938 2 }
3939 else
3940 {
3941
2/4
✓ Branch 0 taken 1162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
1162 if(!p_igetw(&tempMsgString.tile,f,true))
3942 {
3943 return qe_invalid;
3944 }
3945 }
3946
3947
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_getc(&tempMsgString.cset,f,true))
3948 {
3949 return qe_invalid;
3950 }
3951
3952 byte dummy_char;
3953
3954
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
3955 {
3956 return qe_invalid;
3957 }
3958
3959 1164 tempMsgString.trans=dummy_char!=0;
3960
3961
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_getc(&tempMsgString.font,f,true))
3962 {
3963 return qe_invalid;
3964 }
3965
3966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164 times.
1164 if(s_version < 5)
3967 {
3968 if(!p_getc(&tempMsgString.y,f,true))
3969 {
3970 return qe_invalid;
3971 }
3972 }
3973 else
3974 {
3975
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_igetw(&tempMsgString.x,f,true))
3976 {
3977 return qe_invalid;
3978 }
3979
3980
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_igetw(&tempMsgString.y,f,true))
3981 {
3982 return qe_invalid;
3983 }
3984
3985
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_igetw(&tempMsgString.w,f,true))
3986 {
3987 return qe_invalid;
3988 }
3989
3990
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_igetw(&tempMsgString.h,f,true))
3991 {
3992 return qe_invalid;
3993 }
3994
3995
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_getc(&tempMsgString.hspace,f,true))
3996 {
3997 return qe_invalid;
3998 }
3999
4000
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_getc(&tempMsgString.vspace,f,true))
4001 {
4002 return qe_invalid;
4003 }
4004
4005
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_getc(&tempMsgString.stringflags,f,true))
4006 {
4007 return qe_invalid;
4008 }
4009 }
4010
4011
2/2
✓ Branch 0 taken 1162 times.
✓ Branch 1 taken 2 times.
1164 if(s_version >= 7)
4012 {
4013
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 for(int32_t q = 0; q < 4; ++q)
4014 {
4015
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&tempMsgString.margins[q],f,true))
4016 {
4017 return qe_invalid;
4018 }
4019 8 }
4020
4021
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4022 {
4023 return qe_invalid;
4024 }
4025
4026
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4027 {
4028 return qe_invalid;
4029 }
4030
4031
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&tempMsgString.portrait_x,f,true))
4032 {
4033 return qe_invalid;
4034 }
4035
4036
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&tempMsgString.portrait_y,f,true))
4037 {
4038 return qe_invalid;
4039 }
4040
4041
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4042 {
4043 return qe_invalid;
4044 }
4045
4046
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&tempMsgString.portrait_th,f,true))
4047 {
4048 return qe_invalid;
4049 }
4050 2 }
4051
4052
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1162 times.
1164 if(s_version >= 8)
4053 {
4054
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&tempMsgString.shadow_type,f,true))
4055 {
4056 return qe_invalid;
4057 }
4058
4059
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&tempMsgString.shadow_color,f,true))
4060 {
4061 return qe_invalid;
4062 }
4063 2 }
4064
4065
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1162 times.
1164 if(s_version >= 10)
4066 {
4067
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&tempMsgString.drawlayer,f,true))
4068 {
4069 return qe_invalid;
4070 }
4071 2 }
4072
4073
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_getc(&tempMsgString.sfx,f,true))
4074 {
4075 return qe_invalid;
4076 }
4077
4078
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if(s_version>3)
4079 {
4080
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if(!p_igetw(&tempMsgString.listpos,f,true))
4081 {
4082 return qe_invalid;
4083 }
4084 1164 }
4085 }
4086
4087
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if(keepdata==true)
4088 {
4089
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 MsgStrings[i].copyAll(tempMsgString);
4090 1164 }
4091 1164 }
4092 }
4093
4094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
4095 {
4096 25 msg_count=temp_msg_count;
4097 25 }
4098
4099 25 return 0;
4100 25 }
4101
4102 25 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4103 {
4104
1/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if((Header->zelda_version < 0x192)||
4105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4106 {
4107 return 0;
4108 }
4109
4110 25 word temp_door_combo_set_count=0;
4111 DoorComboSet tempDoorComboSet;
4112 word dummy_word;
4113 int32_t dummy_long;
4114 byte padding;
4115 25 int32_t s_version = 0;
4116
4117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
4118 {
4119
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4120 {
4121 6400 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4122 6400 }
4123 25 }
4124
4125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version > 0x192)
4126 {
4127 //section version info
4128
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
4129 {
4130 return qe_invalid;
4131 }
4132
4133 25 FFCore.quest_format[vDoors] = s_version;
4134
4135 //al_trace("Door combo sets version %d\n", dummy_word);
4136
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&dummy_word,f,true))
4137 {
4138 return qe_invalid;
4139 }
4140
4141 //section size
4142
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy_long,f,true))
4143 {
4144 return qe_invalid;
4145 }
4146 25 }
4147
4148 //finally... section data
4149
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_door_combo_set_count,f,true))
4150 {
4151 return qe_invalid;
4152 }
4153
4154
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 25 times.
157 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4155 {
4156 132 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4157
4158 //name
4159
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4160 {
4161 return qe_invalid;
4162 }
4163
4164
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(Header->zelda_version < 0x193)
4165 {
4166 if(!p_getc(&padding,f,true))
4167 {
4168 return qe_invalid;
4169 }
4170 }
4171
4172 //up door
4173
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 132 times.
1320 for(int32_t j=0; j<9; j++)
4174 {
4175
2/2
✓ Branch 0 taken 4752 times.
✓ Branch 1 taken 1188 times.
5940 for(int32_t k=0; k<4; k++)
4176 {
4177
1/2
✓ Branch 0 taken 4752 times.
✗ Branch 1 not taken.
4752 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4178 {
4179 return qe_invalid;
4180 }
4181 4752 }
4182 1188 }
4183
4184
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 132 times.
1320 for(int32_t j=0; j<9; j++)
4185 {
4186
2/2
✓ Branch 0 taken 4752 times.
✓ Branch 1 taken 1188 times.
5940 for(int32_t k=0; k<4; k++)
4187 {
4188
1/2
✓ Branch 0 taken 4752 times.
✗ Branch 1 not taken.
4752 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4189 {
4190 return qe_invalid;
4191 }
4192 4752 }
4193 1188 }
4194
4195 //down door
4196
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 132 times.
1320 for(int32_t j=0; j<9; j++)
4197 {
4198
2/2
✓ Branch 0 taken 4752 times.
✓ Branch 1 taken 1188 times.
5940 for(int32_t k=0; k<4; k++)
4199 {
4200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4752 times.
4752 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4201 {
4202 return qe_invalid;
4203 }
4204 4752 }
4205 1188 }
4206
4207
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 132 times.
1320 for(int32_t j=0; j<9; j++)
4208 {
4209
2/2
✓ Branch 0 taken 4752 times.
✓ Branch 1 taken 1188 times.
5940 for(int32_t k=0; k<4; k++)
4210 {
4211
1/2
✓ Branch 0 taken 4752 times.
✗ Branch 1 not taken.
4752 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4212 {
4213 return qe_invalid;
4214 }
4215 4752 }
4216 1188 }
4217
4218 //left door
4219
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 132 times.
1320 for(int32_t j=0; j<9; j++)
4220 {
4221
2/2
✓ Branch 0 taken 7128 times.
✓ Branch 1 taken 1188 times.
8316 for(int32_t k=0; k<6; k++)
4222 {
4223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7128 times.
7128 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4224 {
4225 return qe_invalid;
4226 }
4227 7128 }
4228 1188 }
4229
4230
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 132 times.
1320 for(int32_t j=0; j<9; j++)
4231 {
4232
2/2
✓ Branch 0 taken 7128 times.
✓ Branch 1 taken 1188 times.
8316 for(int32_t k=0; k<6; k++)
4233 {
4234
1/2
✓ Branch 0 taken 7128 times.
✗ Branch 1 not taken.
7128 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4235 {
4236 return qe_invalid;
4237 }
4238 7128 }
4239 1188 }
4240
4241 //right door
4242
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 132 times.
1320 for(int32_t j=0; j<9; j++)
4243 {
4244
2/2
✓ Branch 0 taken 7128 times.
✓ Branch 1 taken 1188 times.
8316 for(int32_t k=0; k<6; k++)
4245 {
4246
1/2
✓ Branch 0 taken 7128 times.
✗ Branch 1 not taken.
7128 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4247 {
4248 return qe_invalid;
4249 }
4250 7128 }
4251 1188 }
4252
4253
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 132 times.
1320 for(int32_t j=0; j<9; j++)
4254 {
4255
2/2
✓ Branch 0 taken 7128 times.
✓ Branch 1 taken 1188 times.
8316 for(int32_t k=0; k<6; k++)
4256 {
4257
1/2
✓ Branch 0 taken 7128 times.
✗ Branch 1 not taken.
7128 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4258 {
4259 return qe_invalid;
4260 }
4261 7128 }
4262 1188 }
4263
4264 //up bomb rubble
4265
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 132 times.
396 for(int32_t j=0; j<2; j++)
4266 {
4267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4268 {
4269 return qe_invalid;
4270 }
4271 264 }
4272
4273
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 132 times.
396 for(int32_t j=0; j<2; j++)
4274 {
4275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4276 {
4277 return qe_invalid;
4278 }
4279 264 }
4280
4281 //down bomb rubble
4282
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 132 times.
396 for(int32_t j=0; j<2; j++)
4283 {
4284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4285 {
4286 return qe_invalid;
4287 }
4288 264 }
4289
4290
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 132 times.
396 for(int32_t j=0; j<2; j++)
4291 {
4292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4293 {
4294 return qe_invalid;
4295 }
4296 264 }
4297
4298 //left bomb rubble
4299
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 132 times.
528 for(int32_t j=0; j<3; j++)
4300 {
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4302 {
4303 return qe_invalid;
4304 }
4305 396 }
4306
4307
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 132 times.
528 for(int32_t j=0; j<3; j++)
4308 {
4309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4310 {
4311 return qe_invalid;
4312 }
4313 396 }
4314
4315
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(Header->zelda_version < 0x193)
4316 {
4317 if(!p_getc(&padding,f,true))
4318 {
4319 return qe_invalid;
4320 }
4321
4322 }
4323
4324 //right bomb rubble
4325
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 132 times.
528 for(int32_t j=0; j<3; j++)
4326 {
4327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4328 {
4329 return qe_invalid;
4330 }
4331 396 }
4332
4333
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 132 times.
528 for(int32_t j=0; j<3; j++)
4334 {
4335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4336 {
4337 return qe_invalid;
4338 }
4339 396 }
4340
4341
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(Header->zelda_version < 0x193)
4342 {
4343 if(!p_getc(&padding,f,true))
4344 {
4345 return qe_invalid;
4346 }
4347 }
4348
4349 //walkthrough stuff
4350
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t j=0; j<4; j++)
4351 {
4352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
528 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4353 {
4354 return qe_invalid;
4355 }
4356 528 }
4357
4358
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t j=0; j<4; j++)
4359 {
4360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
528 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4361 {
4362 return qe_invalid;
4363 }
4364 528 }
4365
4366 //flags
4367
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 132 times.
396 for(int32_t j=0; j<2; j++)
4368 {
4369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4370 {
4371 return qe_invalid;
4372 }
4373 264 }
4374
4375
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(Header->zelda_version < 0x193)
4376 {
4377 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4378 {
4379 return qe_invalid;
4380 }
4381 }
4382
4383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(keepdata==true)
4384 {
4385 132 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4386 132 }
4387 132 }
4388
4389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
4390 {
4391 25 door_combo_set_count=temp_door_combo_set_count;
4392 25 }
4393
4394 25 return 0;
4395 25 }
4396
4397 int32_t count_dmaps()
4398 {
4399 int32_t i=MAXDMAPS-1;
4400 bool found=false;
4401
4402 while(i>=0 && !found)
4403 {
4404 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4405 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4406 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4407 found=true;
4408
4409 for(int32_t j=0; j<8; j++)
4410 {
4411 if(DMaps[i].grid[j]!=0)
4412
4413 found=true;
4414 }
4415
4416 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4417 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4418 found=true;
4419
4420 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4421 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4422 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4423 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4424 found=true;
4425
4426 if(!found)
4427 {
4428 i--;
4429 }
4430 }
4431
4432 return i+1;
4433 }
4434
4435
4436 int32_t count_shops(miscQdata *Misc)
4437 {
4438 int32_t i=255,j;
4439 bool found=false;
4440
4441 while(i>=0 && !found)
4442 {
4443 j=2;
4444
4445 while(j>=0 && !found)
4446 {
4447 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4448 {
4449 found=true;
4450 }
4451 else
4452 {
4453 j--;
4454 }
4455 }
4456
4457 if(Misc->shop[i].name[0]!=0)
4458 {
4459 found=true;
4460 }
4461
4462 if(!found)
4463 {
4464 i--;
4465 }
4466 }
4467
4468 return i+1;
4469 }
4470
4471 int32_t count_infos(miscQdata *Misc)
4472 {
4473 int32_t i=255,j;
4474 bool found=false;
4475
4476 while(i>=0 && !found)
4477 {
4478 j=2;
4479
4480 while(j>=0 && !found)
4481 {
4482 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4483 {
4484 found=true;
4485 }
4486 else
4487 {
4488 j--;
4489 }
4490 }
4491
4492 if(Misc->info[i].name[0]!=0)
4493 {
4494 found=true;
4495 }
4496
4497 if(!found)
4498 {
4499 i--;
4500 }
4501 }
4502
4503 return i+1;
4504 }
4505
4506 int32_t count_warprings(miscQdata *Misc)
4507 {
4508 int32_t i=15,j;
4509 bool found=false;
4510
4511 while(i>=0 && !found)
4512 {
4513 j=7;
4514
4515 while(j>=0 && !found)
4516 {
4517 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4518 {
4519 found=true;
4520 }
4521 else
4522 {
4523 j--;
4524 }
4525 }
4526
4527 if(!found)
4528 {
4529 i--;
4530 }
4531 }
4532
4533 return i+1;
4534 }
4535
4536 int32_t count_palcycles(miscQdata *Misc)
4537 {
4538 int32_t i=255,j;
4539 bool found=false;
4540
4541 while(i>=0 && !found)
4542 {
4543 j=2;
4544
4545 while(j>=0 && !found)
4546 {
4547 if(Misc->cycles[i][j].count!=0)
4548 {
4549 found=true;
4550 }
4551 else
4552 {
4553 j--;
4554 }
4555 }
4556
4557 if(!found)
4558 {
4559 i--;
4560 }
4561 }
4562
4563 return i+1;
4564 }
4565
4566 31713 void clear_screen(mapscr *temp_scr)
4567 {
4568 31713 temp_scr->zero_memory();
4569 31713 }
4570
4571 25 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4572 {
4573 25 word dmapstoread=0;
4574 dmap tempDMap;
4575
4576 int32_t dummy;
4577 25 word s_version=0, s_cversion=0;
4578 byte padding;
4579
4580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
4581 {
4582
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<max_dmaps; i++)
4583 {
4584 12800 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4585 12800 sprintf(DMaps[start_dmap+i].title," ");
4586 12800 sprintf(DMaps[start_dmap+i].intro," ");
4587 12800 DMaps[start_dmap+i].type |= dmCAVE;
4588 12800 }
4589 25 }
4590
4591
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!Header || Header->zelda_version > 0x192)
4592 {
4593 //section version info
4594
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
4595 {
4596 return qe_invalid;
4597 }
4598
4599 25 FFCore.quest_format[vDMaps] = s_version;
4600
4601 //al_trace("DMaps version %d\n", s_version);
4602
4603
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
4604 {
4605 return qe_invalid;
4606 }
4607
4608 //section size
4609
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
4610 {
4611 return qe_invalid;
4612 }
4613
4614 //finally... section data
4615
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&dmapstoread,f,true))
4616 {
4617 return qe_invalid;
4618 }
4619 25 }
4620 else
4621 {
4622 if((Header->zelda_version < 0x192)||
4623 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4624 {
4625 dmapstoread=32;
4626 }
4627 else if(s_version <= 4)
4628 {
4629 dmapstoread=OLDMAXDMAPS;
4630 }
4631 else
4632 {
4633 dmapstoread=MAXDMAPS;
4634 }
4635 }
4636
4637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 dmapstoread=zc_min(dmapstoread, max_dmaps);
4638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4639
4640
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4641 {
4642 12800 memset(&tempDMap,0,sizeof(dmap));
4643 12800 sprintf(tempDMap.title," ");
4644 12800 sprintf(tempDMap.intro," ");
4645
4646
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.map,f,keepdata))
4647 {
4648 return qe_invalid;
4649 }
4650
4651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(s_version <= 4)
4652 {
4653 byte tempbyte;
4654
4655 if(!p_getc(&tempbyte,f,keepdata))
4656 {
4657 return qe_invalid;
4658 }
4659
4660 tempDMap.level=(word)tempbyte;
4661 }
4662 else
4663 {
4664
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&tempDMap.level,f,keepdata))
4665 {
4666 return qe_invalid;
4667 }
4668 }
4669
4670
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.xoff,f,keepdata))
4671 {
4672 return qe_invalid;
4673 }
4674
4675
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.compass,f,keepdata))
4676 {
4677 return qe_invalid;
4678 }
4679
4680
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(s_version > 8) // February 2009
4681 {
4682
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&tempDMap.color,f,true))
4683 {
4684 return qe_invalid;
4685 }
4686 12800 }
4687 else
4688 {
4689 byte tempbyte;
4690
4691 if(!p_getc(&tempbyte,f,true))
4692 {
4693 return qe_invalid;
4694 }
4695
4696 tempDMap.color = (word)tempbyte;
4697 }
4698
4699
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.midi,f,keepdata))
4700 {
4701 return qe_invalid;
4702 }
4703
4704
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.cont,f,keepdata))
4705 {
4706 return qe_invalid;
4707 }
4708
4709
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.type,f,keepdata))
4710 {
4711 return qe_invalid;
4712 }
4713
4714
3/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12740 times.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
12860 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4715
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4716 60 tempDMap.xoff = 0;
4717
4718
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for(int32_t j=0; j<8; j++)
4719 {
4720
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4721 {
4722 return qe_invalid;
4723 }
4724 102400 }
4725
4726
3/8
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12800 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12800 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12800 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4727 {
4728 if(tempDMap.level>0&&tempDMap.level<10)
4729 {
4730 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4731 }
4732
4733 if(i==0 && Header->zelda_version <= 0x190)
4734 {
4735 tempDMap.cont-=tempDMap.xoff;
4736 tempDMap.compass-=tempDMap.xoff;
4737 }
4738
4739 //forgotten -DD
4740 if(tempDMap.level==0)
4741 {
4742 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4743 }
4744 }
4745 else
4746 {
4747
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4748 {
4749 return qe_invalid;
4750 }
4751
4752
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4753 {
4754 return qe_invalid;
4755 }
4756
4757
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4758 {
4759 return qe_invalid;
4760 }
4761
4762
3/8
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12800 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12800 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12800 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4763 {
4764 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4765 if(keepdata==true)
4766 {
4767 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4768 }
4769
4770 continue;
4771 }
4772
4773
2/4
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12800 times.
✗ Branch 3 not taken.
12800 if(Header && (Header->zelda_version < 0x193))
4774 {
4775 if(!p_getc(&padding,f,keepdata))
4776 {
4777 return qe_invalid;
4778 }
4779 }
4780
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( s_version >= 11 )
4781 {
4782
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4783 {
4784 return qe_invalid;
4785 }
4786 512 }
4787 else
4788 {
4789
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4790 {
4791 return qe_invalid;
4792 }
4793 }
4794
4795
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4796 {
4797 return qe_invalid;
4798 }
4799
4800
2/4
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12800 times.
✗ Branch 3 not taken.
12800 if(Header && (Header->zelda_version < 0x193))
4801 {
4802 if(!p_getc(&padding,f,keepdata))
4803 {
4804 return qe_invalid;
4805 }
4806 }
4807
4808
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( s_version >= 11 )
4809 {
4810
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4811 {
4812 return qe_invalid;
4813 }
4814 512 }
4815 else
4816 {
4817
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4818 {
4819 return qe_invalid;
4820 }
4821 }
4822
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4823 {
4824 return qe_invalid;
4825 }
4826
4827
2/4
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12800 times.
✗ Branch 3 not taken.
12800 if(Header && (Header->zelda_version < 0x193))
4828 {
4829 if(!p_getc(&padding,f,keepdata))
4830 {
4831 return qe_invalid;
4832 }
4833 }
4834
4835
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( s_version >= 11 )
4836 {
4837
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4838 {
4839 return qe_invalid;
4840 }
4841 512 }
4842 else
4843 {
4844
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4845 {
4846 return qe_invalid;
4847 }
4848 }
4849
4850
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4851 {
4852 return qe_invalid;
4853 }
4854
4855
2/4
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12800 times.
✗ Branch 3 not taken.
12800 if(Header && (Header->zelda_version < 0x193))
4856 {
4857
4858 if(!p_getc(&padding,f,keepdata))
4859 {
4860 return qe_invalid;
4861 }
4862 }
4863
4864
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( s_version >= 11 )
4865 {
4866
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4867 {
4868 return qe_invalid;
4869 }
4870 512 }
4871 else
4872 {
4873
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4874 {
4875 return qe_invalid;
4876 }
4877 }
4878
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4879 {
4880 return qe_invalid;
4881 }
4882
4883
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4884 {
4885 return qe_invalid;
4886 }
4887 }
4888
4889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(s_version>1)
4890 {
4891
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4892 {
4893 return qe_invalid;
4894 }
4895
4896
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4897 {
4898 return qe_invalid;
4899 }
4900
4901
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
4902 {
4903 return qe_invalid;
4904 }
4905 12800 }
4906
4907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(s_version>2)
4908 {
4909 byte di[32];
4910
4911
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!pfread(&di, 32, f, true)) return qe_invalid;
4912
4913
2/2
✓ Branch 0 taken 3276800 times.
✓ Branch 1 taken 12800 times.
3289600 for(int32_t j=0; j<MAXITEMS; j++)
4914 {
4915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3276800 times.
3276800 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4916 3276800 else tempDMap.disableditems[j]=0;
4917 3276800 }
4918 12800 }
4919
4920
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(s_version >= 6)
4921 {
4922
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&tempDMap.flags,f,keepdata))
4923 {
4924 return qe_invalid;
4925 }
4926 12800 }
4927 else if(s_version>3)
4928 {
4929 char temp;
4930
4931 if(!p_getc(&temp,f,keepdata))
4932 {
4933 return qe_invalid;
4934 }
4935
4936 tempDMap.flags = temp;
4937 }
4938 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4939 {
4940 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4941 }
4942 else
4943 tempDMap.flags=0;
4944
4945
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(s_version<7)
4946 {
4947 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4948 tempDMap.flags|= dmfVIEWMAP;
4949 }
4950
4951
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(s_version<8)
4952 {
4953 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4954 {
4955 tempDMap.type &= ~dmDNGN;
4956 tempDMap.type |= dmCAVE;
4957 }
4958 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4959 {
4960 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4961 }
4962 }
4963
4964
3/8
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12800 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 12800 times.
✗ Branch 7 not taken.
12800 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4965 12800 && (Header->zelda_version < 0x193))
4966 {
4967 if(!p_getc(&padding,f,keepdata))
4968 {
4969 return qe_invalid;
4970 }
4971 }
4972
4973
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(s_version >= 10)
4974 {
4975
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&tempDMap.sideview,f,keepdata))
4976 {
4977 return qe_invalid;
4978 }
4979 512 }
4980
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(s_version < 10) tempDMap.sideview = 0;
4981
4982 //Dmap Scripts
4983
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(s_version >= 12)
4984 {
4985
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempDMap.script,f,keepdata))
4986 {
4987 return qe_invalid;
4988 }
4989
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for ( int32_t q = 0; q < 8; q++ )
4990 {
4991
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
4992 {
4993 return qe_invalid;
4994 }
4995 4096 }
4996 512 }
4997
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( s_version < 12 )
4998 {
4999 12288 tempDMap.script = 0;
5000
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; q++ )
5001 {
5002 98304 tempDMap.initD[q] = 0;
5003 98304 }
5004 12288 }
5005
5006
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(s_version >= 13)
5007 {
5008
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for ( int32_t q = 0; q < 8; q++ )
5009 {
5010
2/2
✓ Branch 0 taken 266240 times.
✓ Branch 1 taken 4096 times.
270336 for ( int32_t w = 0; w < 65; w++ )
5011 {
5012
1/2
✓ Branch 0 taken 266240 times.
✗ Branch 1 not taken.
266240 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5013 {
5014 return qe_invalid;
5015 }
5016 266240 }
5017 4096 }
5018 512 }
5019
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( s_version < 13 )
5020 {
5021 12288 tempDMap.script = 0;
5022
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; q++ )
5023 {
5024
2/2
✓ Branch 0 taken 6389760 times.
✓ Branch 1 taken 98304 times.
6488064 for ( int32_t w = 0; w < 65; w++ )
5025 6389760 tempDMap.initD_label[q][w] = 0;
5026 98304 }
5027 12288 }
5028
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(s_version >= 14)
5029 {
5030
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5031 {
5032 return qe_invalid;
5033 }
5034
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5035 {
5036 return qe_invalid;
5037 }
5038
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for ( int32_t q = 0; q < 8; ++q )
5039 {
5040
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5041 {
5042 return qe_invalid;
5043 }
5044 4096 }
5045
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for(int32_t q = 0; q < 8; ++q)
5046 {
5047
2/2
✓ Branch 0 taken 266240 times.
✓ Branch 1 taken 4096 times.
270336 for ( int32_t w = 0; w < 65; ++w )
5048 {
5049
1/2
✓ Branch 0 taken 266240 times.
✗ Branch 1 not taken.
266240 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5050 {
5051 return qe_invalid;
5052 }
5053 266240 }
5054 4096 }
5055 512 }
5056 else
5057 {
5058 12288 tempDMap.active_sub_script = 0;
5059 12288 tempDMap.passive_sub_script = 0;
5060
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for(int32_t q = 0; q < 8; ++q)
5061 {
5062 98304 tempDMap.sub_initD[q] = 0;
5063
2/2
✓ Branch 0 taken 6389760 times.
✓ Branch 1 taken 98304 times.
6488064 for(int32_t w = 0; w < 65; ++w)
5064 6389760 tempDMap.sub_initD_label[q][w] = 0;
5065 98304 }
5066 }
5067
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(s_version >= 15)
5068 {
5069
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5070 {
5071 return qe_invalid;
5072 }
5073
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for ( int32_t q = 0; q < 8; ++q )
5074 {
5075
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5076 {
5077 return qe_invalid;
5078 }
5079 4096 }
5080
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for(int32_t q = 0; q < 8; ++q)
5081 {
5082
2/2
✓ Branch 0 taken 266240 times.
✓ Branch 1 taken 4096 times.
270336 for ( int32_t w = 0; w < 65; ++w )
5083 {
5084
1/2
✓ Branch 0 taken 266240 times.
✗ Branch 1 not taken.
266240 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5085 {
5086 return qe_invalid;
5087 }
5088 266240 }
5089 4096 }
5090 512 }
5091 else
5092 {
5093 12288 tempDMap.onmap_script = 0;
5094
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for(int32_t q = 0; q < 8; ++q)
5095 {
5096 98304 tempDMap.onmap_initD[q] = 0;
5097
2/2
✓ Branch 0 taken 6389760 times.
✓ Branch 1 taken 98304 times.
6488064 for(int32_t w = 0; w < 65; ++w)
5098 {
5099 6389760 tempDMap.onmap_initD_label[q][w] = 0;
5100 6389760 }
5101 98304 }
5102 }
5103
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(s_version >= 16)
5104 {
5105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5106 {
5107 return qe_invalid;
5108 }
5109 512 }
5110 else
5111 {
5112 12288 tempDMap.mirrorDMap = -1;
5113 }
5114
5115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(keepdata==true)
5116 {
5117 12800 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5118 12800 }
5119 12800 }
5120
5121 25 return 0;
5122 25 }
5123
5124 25 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5125 {
5126 //these are here to bypass compiler warnings about unused arguments
5127 25 Header=Header;
5128
5129 miscQdata temp_misc;
5130 25 word s_version=0, s_cversion=0;
5131 25 int32_t tempsize=0;
5132 word dummyw;
5133
5134 25 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5135
5136 //section version info
5137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&s_version,f,true))
5138 {
5139 return qe_invalid;
5140 }
5141
5142 25 FFCore.quest_format[vColours] = s_version;
5143
5144 25 al_trace("Misc Colours section version: %d\n", s_version);
5145
5146 //al_trace("Misc. colors version %d\n", s_version);
5147
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
5148 {
5149 return qe_invalid;
5150 }
5151
5152
5153 //section size
5154
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempsize,f,true))
5155 {
5156 return qe_invalid;
5157 }
5158
5159 //finally... section data
5160 25 readsize=0;
5161
5162
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.text,f,true))
5163 {
5164 return qe_invalid;
5165 }
5166
5167
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.caption,f,true))
5168 {
5169 return qe_invalid;
5170 }
5171
5172
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5173 {
5174 return qe_invalid;
5175 }
5176
5177
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5178 {
5179 return qe_invalid;
5180 }
5181
5182
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5183 {
5184 return qe_invalid;
5185 }
5186
5187
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5188 {
5189 return qe_invalid;
5190 }
5191
5192
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5193 {
5194 return qe_invalid;
5195 }
5196
5197
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5198 {
5199 return qe_invalid;
5200 }
5201
5202
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5203 {
5204 return qe_invalid;
5205 }
5206
5207
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5208 {
5209 return qe_invalid;
5210 }
5211
5212
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5213 {
5214 return qe_invalid;
5215 }
5216
5217
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5218 {
5219 return qe_invalid;
5220 }
5221
5222
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5223 {
5224 return qe_invalid;
5225 }
5226
5227
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5228 {
5229 return qe_invalid;
5230 }
5231
5232
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5233 {
5234 return qe_invalid;
5235 }
5236
5237
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5238 {
5239 return qe_invalid;
5240 }
5241
5242
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5243 {
5244 return qe_invalid;
5245 }
5246
5247
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5248 {
5249 return qe_invalid;
5250 }
5251
5252
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5253 {
5254 return qe_invalid;
5255 }
5256
5257
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5258 {
5259 return qe_invalid;
5260 }
5261
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version < 4)
5262 {
5263
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&dummyw,f,true))
5264 return qe_invalid;
5265 24 temp_misc.colors.triforce_tile = dummyw;
5266
5267
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&dummyw,f,true))
5268 return qe_invalid;
5269 24 temp_misc.colors.triframe_tile = dummyw;
5270
5271
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&dummyw,f,true))
5272 return qe_invalid;
5273 24 temp_misc.colors.overworld_map_tile = dummyw;
5274
5275
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&dummyw,f,true))
5276 return qe_invalid;
5277 24 temp_misc.colors.dungeon_map_tile = dummyw;
5278
5279
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&dummyw,f,true))
5280 return qe_invalid;
5281 24 temp_misc.colors.blueframe_tile = dummyw;
5282
5283
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&dummyw,f,true))
5284 return qe_invalid;
5285 24 temp_misc.colors.HCpieces_tile = dummyw;
5286 24 }
5287
5288
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5294 {
5295 return qe_invalid;
5296 }
5297
5298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version < 2)
5299 {
5300 temp_misc.colors.msgtext = 0x01;
5301 }
5302 else
5303 {
5304
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5305 {
5306 return qe_invalid;
5307 }
5308 }
5309
5310
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if ( s_version >= 3 ) //expanded tile pages to 825
5311 {
5312
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5313 {
5314 return qe_invalid;
5315 }
5316
5317
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5318 {
5319 return qe_invalid;
5320 }
5321
5322
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5323 {
5324 return qe_invalid;
5325 }
5326
5327
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5328 {
5329 return qe_invalid;
5330 }
5331
5332
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5333 {
5334 return qe_invalid;
5335 }
5336
5337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5338 {
5339 return qe_invalid;
5340 }
5341 1 }
5342
5343
5344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
5345 {
5346 25 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5347 25 }
5348
5349 25 return 0;
5350 25 }
5351
5352 25 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5353 {
5354 miscQdata temp_misc;
5355 25 word s_version=0, s_cversion=0;
5356 byte icons;
5357 25 int32_t tempsize=0;
5358
5359 25 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5360
5361 //section version info
5362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&s_version,f,true))
5363 {
5364 return qe_invalid;
5365 }
5366
5367 25 FFCore.quest_format[vIcons] = s_version;
5368
5369 //al_trace("Game icons version %d\n", s_version);
5370
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
5371 {
5372 return qe_invalid;
5373 }
5374
5375
5376 //section size
5377
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempsize,f,true))
5378 {
5379 return qe_invalid;
5380 }
5381
5382 //finally... section data
5383 25 readsize=0;
5384
5385 25 icons=4;
5386
5387
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( s_version >= 10 )
5388 {
5389
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<icons; i++)
5390 {
5391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetl(&temp_misc.icons[i],f,true))
5392 {
5393 return qe_invalid;
5394 }
5395 4 }
5396 1 }
5397 else
5398 {
5399
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<icons; i++)
5400 {
5401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&temp_misc.icons[i],f,true))
5402 {
5403 return qe_invalid;
5404 }
5405 96 }
5406 }
5407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
5408 {
5409 25 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5410 25 }
5411
5412 25 return 0;
5413 25 }
5414
5415 25 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5416 {
5417 25 word maxinfos=256;
5418 25 word maxshops=256;
5419 25 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5420 25 word ponds=16, pondsize=72, expansionsize=98*2;
5421 byte tempbyte, padding;
5422 miscQdata temp_misc;
5423 25 word s_version=0, s_cversion=0;
5424 word swaptmp;
5425 25 int32_t tempsize=0;
5426
5427 25 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5428
5429
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<maxshops; ++i)
5430 {
5431 6400 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5432 6400 }
5433
5434
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<maxinfos; ++i)
5435 {
5436 6400 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5437 6400 }
5438
5439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version > 0x192)
5440 {
5441 //section version info
5442
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
5443 {
5444 return qe_invalid;
5445 }
5446
5447 25 FFCore.quest_format[vMisc] = s_version;
5448
5449 //al_trace("Misc. data version %d\n", s_version);
5450
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
5451 {
5452 return qe_invalid;
5453 }
5454
5455
5456 //section size
5457
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempsize,f,true))
5458 {
5459 return qe_invalid;
5460 }
5461 25 }
5462
5463 //finally... section data
5464 25 readsize=0;
5465
5466 //shops
5467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version > 0x192)
5468 {
5469
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&shops,f,true))
5470 {
5471 return qe_invalid;
5472 }
5473 25 }
5474
5475
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 25 times.
279 for(int32_t i=0; i<shops; i++)
5476 {
5477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
254 if(s_version > 6)
5478 {
5479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
254 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5480 {
5481 return qe_invalid;
5482 }
5483 254 }
5484
5485
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 254 times.
1016 for(int32_t j=0; j<3; j++)
5486 {
5487
1/2
✓ Branch 0 taken 762 times.
✗ Branch 1 not taken.
762 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5488 {
5489 return qe_invalid;
5490 }
5491
5492
1/2
✓ Branch 0 taken 762 times.
✗ Branch 1 not taken.
762 if(s_version < 4)
5493 {
5494 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5495 }
5496 762 }
5497
5498
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 if(Header->zelda_version < 0x193)
5499 {
5500 if(!p_getc(&tempbyte,f,true))
5501 {
5502 return qe_invalid;
5503 }
5504 }
5505
5506
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 254 times.
1016 for(int32_t j=0; j<3; j++)
5507 {
5508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 762 times.
762 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5509 {
5510 return qe_invalid;
5511 }
5512 762 }
5513
5514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
254 if(s_version > 3)
5515 {
5516
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 254 times.
1016 for(int32_t j=0; j<3; j++)
5517 {
5518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 762 times.
762 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5519 return qe_invalid;
5520 762 }
5521 254 }
5522
5523 /*
5524 if(s_version < 8)
5525 {
5526 for(int32_t j=0; j<3; j++)
5527 {
5528 (&temp_misc.shop[i].str[j])=0; //initialise.
5529 }
5530 }
5531 */
5532 254 }
5533
5534 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5535
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<maxshops; ++i)
5536 {
5537
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 6400 times.
19200 for(int32_t j=0; j<3-1; j++)
5538 {
5539
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 12800 times.
32000 for(int32_t k=0; k<2-j; k++)
5540 {
5541
2/2
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 18548 times.
19200 if(temp_misc.shop[i].hasitem[k]==0)
5542 {
5543 18548 swaptmp = temp_misc.shop[i].item[k];
5544 18548 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5545 18548 temp_misc.shop[i].item[k+1] = swaptmp;
5546 18548 swaptmp = temp_misc.shop[i].price[k];
5547 18548 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5548 18548 temp_misc.shop[i].price[k+1] = swaptmp;
5549 18548 swaptmp = temp_misc.shop[i].hasitem[k];
5550 18548 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5551 18548 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5552 18548 }
5553 19200 }
5554 12800 }
5555 6400 }
5556
5557 //infos
5558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version > 0x192)
5559 {
5560
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&infos,f,true))
5561 {
5562 return qe_invalid;
5563 }
5564 25 }
5565
5566
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 25 times.
361 for(int32_t i=0; i<infos; i++)
5567 {
5568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
336 if(s_version > 6)
5569 {
5570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
336 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5571 {
5572 return qe_invalid;
5573 }
5574 336 }
5575
5576
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 for(int32_t j=0; j<3; j++)
5577 {
5578
1/4
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1008 if((Header->zelda_version < 0x192)||
5579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1008 times.
1008 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5580 {
5581 if(!p_getc(&tempbyte,f,true))
5582 {
5583 return qe_invalid;
5584 }
5585
5586 temp_misc.info[i].str[j]=tempbyte;
5587 }
5588 else
5589 {
5590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1008 times.
1008 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5591 {
5592 return qe_invalid;
5593 }
5594 }
5595 1008 }
5596
5597
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(Header->zelda_version < 0x193)
5598 {
5599 if(!p_getc(&tempbyte,f,true))
5600 {
5601 return qe_invalid;
5602 }
5603 }
5604
5605
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 if((Header->zelda_version == 0x192)&&(Header->build>145))
5606 {
5607 if(!p_getc(&padding,f,true))
5608 {
5609 return qe_invalid;
5610 }
5611 }
5612
5613
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 for(int32_t j=0; j<3; j++)
5614 {
5615
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5616 {
5617 return qe_invalid;
5618 }
5619 1008 }
5620 336 }
5621
5622 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5623
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<maxinfos; ++i)
5624 {
5625
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 6400 times.
19200 for(int32_t j=0; j<3-1; j++)
5626 {
5627
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 12800 times.
32000 for(int32_t k=0; k<2-j; k++)
5628 {
5629
2/2
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 18807 times.
19200 if(temp_misc.info[i].str[k]==0)
5630 {
5631 18807 swaptmp = temp_misc.info[i].str[k];
5632 18807 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5633 18807 temp_misc.info[i].str[k+1] = swaptmp;
5634 18807 swaptmp = temp_misc.info[i].price[k];
5635 18807 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5636 18807 temp_misc.info[i].price[k+1] = swaptmp;
5637 18807 }
5638 19200 }
5639 12800 }
5640 6400 }
5641
5642
5643 //warp rings
5644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version > 5)
5645 25 warprings++;
5646
5647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version > 0x192)
5648 {
5649
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&warprings,f,true))
5650 {
5651 return qe_invalid;
5652 }
5653 25 }
5654
5655
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 25 times.
272 for(int32_t i=0; i<warprings; i++)
5656 {
5657
2/2
✓ Branch 0 taken 2223 times.
✓ Branch 1 taken 247 times.
2470 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5658 {
5659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2223 times.
2223 if(s_version <= 3)
5660 {
5661 if(!p_getc(&tempbyte,f,true))
5662 {
5663 return qe_invalid;
5664 }
5665
5666 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5667 }
5668 else
5669 {
5670
1/2
✓ Branch 0 taken 2223 times.
✗ Branch 1 not taken.
2223 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5671 {
5672 return qe_invalid;
5673 }
5674 }
5675 2223 }
5676
5677
2/2
✓ Branch 0 taken 2223 times.
✓ Branch 1 taken 247 times.
2470 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5678 {
5679
1/2
✓ Branch 0 taken 2223 times.
✗ Branch 1 not taken.
2223 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5680 {
5681 return qe_invalid;
5682 }
5683 2223 }
5684
5685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247 times.
247 if(!p_getc(&temp_misc.warp[i].size,f,true))
5686 {
5687 return qe_invalid;
5688 }
5689
5690
1/2
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
247 if(Header->zelda_version < 0x193)
5691 {
5692 if(!p_getc(&tempbyte,f,true))
5693 {
5694 return qe_invalid;
5695 }
5696 }
5697 247 }
5698
5699 //palette cycles
5700
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5701 {
5702 for(int32_t i=0; i<256; i++)
5703 {
5704 for(int32_t j=0; j<3; j++)
5705 {
5706 temp_misc.cycles[i][j].first=0;
5707 temp_misc.cycles[i][j].count=0;
5708 temp_misc.cycles[i][j].speed=0;
5709 }
5710 }
5711
5712 if((Header->zelda_version < 0x192)||
5713 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5714 {
5715 palcycles=16;
5716 }
5717
5718 for(int32_t i=0; i<palcycles; i++)
5719 {
5720 for(int32_t j=0; j<3; j++)
5721 {
5722 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5723 {
5724 return qe_invalid;
5725 }
5726
5727 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5728 {
5729 return qe_invalid;
5730 }
5731
5732 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5733 {
5734 return qe_invalid;
5735 }
5736 }
5737 }
5738 }
5739
5740 //Wind warps are now just another warp ring.
5741
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version <= 5)
5742 {
5743 if(Header->zelda_version > 0x192)
5744 {
5745 if(!p_igetw(&windwarps,f,true))
5746 {
5747 return qe_invalid;
5748 }
5749 }
5750
5751 for(int32_t i=0; i<windwarps; i++)
5752 {
5753 if(s_version <= 3)
5754 {
5755 if(!p_getc(&tempbyte,f,true))
5756 {
5757 return qe_invalid;
5758 }
5759
5760 temp_misc.warp[8].dmap[i]=tempbyte;
5761 }
5762 else
5763 {
5764 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5765 {
5766 return qe_invalid;
5767 }
5768 }
5769
5770 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5771 {
5772 return qe_invalid;
5773 }
5774
5775 temp_misc.warp[8].size = 9;
5776
5777 if(s_version == 5)
5778 {
5779 if(!p_getc(&tempbyte,f,true))
5780 {
5781 return qe_invalid;
5782 }
5783 }
5784 }
5785 }
5786
5787
5788 //triforce pieces
5789
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 25 times.
225 for(int32_t i=0; i<triforces; i++)
5790 {
5791
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&temp_misc.triforce[i],f,true))
5792 {
5793 return qe_invalid;
5794 }
5795 200 }
5796
5797 //misc color data
5798
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<3)
5799 {
5800 if(!p_getc(&temp_misc.colors.text,f,true))
5801 {
5802 return qe_invalid;
5803 }
5804
5805 if(!p_getc(&temp_misc.colors.caption,f,true))
5806 {
5807 return qe_invalid;
5808 }
5809
5810 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5811 {
5812 return qe_invalid;
5813 }
5814
5815 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5816 {
5817 return qe_invalid;
5818 }
5819
5820 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5821 {
5822 return qe_invalid;
5823 }
5824
5825 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5826 {
5827 return qe_invalid;
5828 }
5829
5830 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5831 {
5832 return qe_invalid;
5833 }
5834
5835 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5836 {
5837 return qe_invalid;
5838 }
5839
5840 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5841 {
5842 return qe_invalid;
5843 }
5844
5845 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5846 {
5847 return qe_invalid;
5848 }
5849
5850 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5851 {
5852 return qe_invalid;
5853 }
5854
5855 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5856 {
5857 return qe_invalid;
5858 }
5859
5860 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5861 {
5862 return qe_invalid;
5863 }
5864
5865 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5866 {
5867 return qe_invalid;
5868 }
5869
5870 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5871 {
5872 return qe_invalid;
5873 }
5874
5875 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5876 {
5877 return qe_invalid;
5878 }
5879
5880 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5881 {
5882 return qe_invalid;
5883 }
5884
5885 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5886 {
5887 return qe_invalid;
5888 }
5889
5890 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5891 {
5892 return qe_invalid;
5893 }
5894
5895 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5896 {
5897 return qe_invalid;
5898 }
5899
5900 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
5901 {
5902 return qe_invalid;
5903 }
5904
5905 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
5906 {
5907 return qe_invalid;
5908 }
5909
5910 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
5911 {
5912 return qe_invalid;
5913 }
5914
5915 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
5916 {
5917 return qe_invalid;
5918 }
5919
5920 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
5921 {
5922 return qe_invalid;
5923 }
5924
5925 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
5926 {
5927 return qe_invalid;
5928 }
5929
5930 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5931 {
5932 return qe_invalid;
5933 }
5934
5935 temp_misc.colors.msgtext = 0x01;
5936
5937 if(Header->zelda_version < 0x193)
5938 {
5939 for(int32_t i=0; i<7; i++)
5940 {
5941 if(!p_getc(&tempbyte,f,true))
5942 {
5943 return qe_invalid;
5944 }
5945 }
5946 }
5947
5948 if((Header->zelda_version == 0x192)&&(Header->build>145))
5949 {
5950 for(int32_t i=0; i<256; i++)
5951 {
5952 if(!p_getc(&tempbyte,f,true))
5953 {
5954 return qe_invalid;
5955 }
5956 }
5957 }
5958
5959 if(s_version>1)
5960 {
5961 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5962 {
5963 return qe_invalid;
5964 }
5965 }
5966
5967 //save game icons
5968 if((Header->zelda_version < 0x192)||
5969 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5970 {
5971 icons=3;
5972 }
5973
5974 for(int32_t i=0; i<icons; i++)
5975 {
5976 if(!p_igetw(&temp_misc.icons[i],f,true))
5977 {
5978 return qe_invalid;
5979 }
5980 }
5981 }
5982
5983
1/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if((Header->zelda_version < 0x192)||
5984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5985 {
5986 if(keepdata==true)
5987 {
5988 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5989 }
5990
5991 return 0;
5992 }
5993
5994 //pond information
5995
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x193)
5996 {
5997 if((Header->zelda_version == 0x192)&&(Header->build<146))
5998 {
5999 pondsize=25;
6000 }
6001
6002 for(int32_t i=0; i<ponds; i++)
6003 {
6004 for(int32_t j=0; j<pondsize; j++)
6005 {
6006 if(!p_getc(&tempbyte,f,true))
6007 {
6008 return qe_invalid;
6009
6010 }
6011 }
6012 }
6013 }
6014
6015 //end string
6016
1/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if((Header->zelda_version < 0x192)||
6017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6018 {
6019 if(!p_getc(&tempbyte,f,true))
6020 {
6021 return qe_invalid;
6022 }
6023
6024 temp_misc.endstring=tempbyte;
6025
6026 if(!p_getc(&tempbyte,f,true))
6027 {
6028 return qe_invalid;
6029 }
6030 }
6031 else
6032 {
6033
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_misc.endstring,f,true))
6034 {
6035 return qe_invalid;
6036 }
6037 }
6038
6039 //expansion
6040
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x193)
6041 {
6042 if((Header->zelda_version == 0x192)&&(Header->build<73))
6043 {
6044 expansionsize=99*2;
6045 }
6046
6047 for(int32_t i=0; i<expansionsize; i++)
6048 {
6049 if(!p_getc(&tempbyte,f,true))
6050 {
6051 return qe_invalid;
6052 }
6053 }
6054 }
6055 //shops v8
6056
6057
6058
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version >= 8)
6059 {
6060
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 for(int32_t i=0; i<shops; i++)
6061 {
6062
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for(int32_t j=0; j<3; j++)
6063 {
6064
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6065 return qe_invalid;
6066 48 }
6067 16 }
6068 1 }
6069
6070 25 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6071 25 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6072 25 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6073
6074 //v9 includes quest misc[32]
6075
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version >= 9)
6076 {
6077
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for ( int32_t q = 0; q < 32; q++ )
6078 {
6079
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6080 return qe_invalid;
6081 32 }
6082
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for ( int32_t q = 0; q < 32; q++ )
6083 {
6084
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 32 times.
4128 for ( int32_t j = 0; j < 128; j++ )
6085
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6086 return qe_invalid;
6087 32 }
6088 1 }
6089
6090
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version >= 11 )
6091 {
6092
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6093 return qe_invalid;
6094 1 }
6095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 else if(s_version < 11 )
6096 {
6097 24 temp_misc.zscript_last_compiled_version = -1;
6098 24 }
6099
6100 25 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6101
6102
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version >= 12)
6103 {
6104 byte spr;
6105
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t q = 0; q < sprMAX; ++q)
6106 {
6107
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&spr,f,true))
6108 return qe_invalid;
6109 256 temp_misc.sprites[q] = spr;
6110 256 }
6111 1 }
6112 else
6113 {
6114 24 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6115 //temp_misc.sprites[sprFALL] = ;
6116 }
6117
6118
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version >= 13)
6119 {
6120
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1 times.
65 for(size_t q = 0; q < 64; ++q)
6121 {
6122 64 bottletype* bt = &(temp_misc.bottle_types[q]);
6123
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if (!pfread(bt->name, 32, f, true))
6124 return qe_invalid;
6125
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(size_t j = 0; j < 3; ++j)
6126 {
6127
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (!p_getc(&(bt->counter[j]), f, true))
6128 return qe_invalid;
6129
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (!p_igetw(&(bt->amount[j]), f, true))
6130 return qe_invalid;
6131 192 }
6132
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if (!p_getc(&(bt->flags), f, true))
6133 return qe_invalid;
6134
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if (!p_getc(&(bt->next_type), f, true))
6135 return qe_invalid;
6136 64 }
6137
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(size_t q = 0; q < 256; ++q)
6138 {
6139 256 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6140
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if (!pfread(bst->name, 32, f, true))
6141 return qe_invalid;
6142
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 256 times.
1024 for(size_t j = 0; j < 3; ++j)
6143 {
6144
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if (!p_getc(&(bst->fill[j]), f, true))
6145 return qe_invalid;
6146
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if (!p_igetw(&(bst->comb[j]), f, true))
6147 return qe_invalid;
6148
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if (!p_getc(&(bst->cset[j]), f, true))
6149 return qe_invalid;
6150
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if (!p_igetw(&(bst->price[j]), f, true))
6151 return qe_invalid;
6152
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if (!p_igetw(&(bst->str[j]), f, true))
6153 return qe_invalid;
6154 768 }
6155 256 }
6156 1 }
6157 else
6158 {
6159
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 24 times.
1560 for(size_t q = 0; q < 64; ++q)
6160 1536 temp_misc.bottle_types[q].clear();
6161
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(size_t q = 0; q < 256; ++q)
6162 6144 temp_misc.bottle_shop_types[q].clear();
6163 }
6164
6165
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version >= 14)
6166 {
6167 byte msfx;
6168
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t q = 0; q < sfxMAX; ++q)
6169 {
6170
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&msfx,f,true))
6171 return qe_invalid;
6172 256 temp_misc.miscsfx[q] = msfx;
6173 256 }
6174 1 }
6175 else
6176 {
6177 24 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6178 24 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6179 24 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6180 }
6181
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version < 15)
6182 {
6183 24 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6184 24 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6185 24 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6186 24 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6187 24 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6188 24 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6189 24 }
6190
6191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
6192 {
6193 25 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6194 25 }
6195
6196 25 return 0;
6197 25 }
6198
6199 extern char *item_string[ITEMCNT];
6200 extern const char *old_item_string[iLast];
6201 extern char *weapon_string[WPNCNT];
6202 extern const char *old_weapon_string[wLast];
6203
6204 25 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6205 {
6206 byte padding;
6207 int32_t dummy;
6208 25 word items_to_read=MAXITEMS;
6209 itemdata tempitem;
6210 25 word s_version=0, s_cversion=0;
6211 word dummy_word;
6212
6213
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(version < 0x186)
6214 {
6215 items_to_read=64;
6216 }
6217
6218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(version > 0x192)
6219 {
6220 25 items_to_read=0;
6221
6222 //section version info
6223
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
6224 {
6225 return qe_invalid;
6226 }
6227
6228 25 FFCore.quest_format[vItems] = s_version;
6229
6230 //al_trace("Items version %d\n", s_version);
6231
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
6232 {
6233 return qe_invalid;
6234 }
6235
6236 //section size
6237
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
6238 {
6239 return qe_invalid;
6240 }
6241
6242 //finally... section data
6243
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&items_to_read,f,true))
6244 {
6245 return qe_invalid;
6246 }
6247 25 }
6248
6249
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version>1)
6250 {
6251
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<items_to_read; i++)
6252 {
6253 char tempname[64];
6254
6255
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!pfread(tempname, 64, f, keepdata))
6256 {
6257 return qe_invalid;
6258 }
6259
6260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(keepdata)
6261 {
6262 6400 strcpy(item_string[i], tempname);
6263 6400 }
6264 6400 }
6265 25 }
6266 else
6267 {
6268 if(keepdata)
6269 {
6270 for(int32_t i=0; i<ITEMCNT; i++)
6271 {
6272 reset_itemname(i);
6273 }
6274 }
6275 }
6276
6277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
6278 {
6279
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<MAXITEMS; i++)
6280 {
6281 6400 itemdata& id = itemsbuf[i];
6282 6400 memset(&id, 0, sizeof(itemdata));
6283 6400 id.count=-1;
6284 6400 id.playsound=WAV_SCALE;
6285 6400 reset_itembuf(&id,i);
6286 6400 }
6287 25 }
6288
6289
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<items_to_read; i++)
6290 {
6291 6400 memset(&tempitem, 0, sizeof(itemdata));
6292 6400 reset_itembuf(&tempitem,i);
6293
6294
6295
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if ( s_version > 35 ) //expanded tiles
6296 {
6297
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.tile,f,true))
6298 {
6299 return qe_invalid;
6300 }
6301 256 }
6302 else
6303 {
6304
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetw(&tempitem.tile,f,true))
6305 {
6306 return qe_invalid;
6307 }
6308 }
6309
6310
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.misc_flags,f,true))
6311 {
6312 return qe_invalid;
6313 }
6314
6315
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.csets,f,true))
6316 {
6317 return qe_invalid;
6318 }
6319
6320
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.frames,f,true))
6321 {
6322 return qe_invalid;
6323 }
6324
6325
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.speed,f,true))
6326 {
6327 return qe_invalid;
6328 }
6329
6330
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.delay,f,true))
6331 {
6332 return qe_invalid;
6333 }
6334
6335
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(version < 0x193)
6336 {
6337 if(!p_getc(&padding,f,true))
6338 {
6339 return qe_invalid;
6340 }
6341
6342 if((version < 0x192)||((version == 0x192)&&(build<186)))
6343 {
6344 switch(i)
6345 {
6346 case iShield:
6347 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6348 break;
6349
6350 case iMShield:
6351 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6352 break;
6353
6354 default:
6355 tempitem.ltm=0;
6356 break;
6357 }
6358
6359 tempitem.count=-1;
6360 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6361 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6362 tempitem.family=0xFF;
6363 tempitem.playsound=WAV_SCALE;
6364 reset_itembuf(&tempitem,i);
6365
6366 if(keepdata==true)
6367 {
6368 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6369 }
6370
6371 continue;
6372 }
6373 }
6374
6375
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.ltm,f,true))
6376 {
6377 return qe_invalid;
6378 }
6379
6380
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(version < 0x193)
6381 {
6382 for(int32_t q=0; q<12; q++)
6383 {
6384 if(!p_getc(&padding,f,true))
6385 {
6386 return qe_invalid;
6387 }
6388 }
6389 }
6390
6391
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version>1)
6392 {
6393
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if ( s_version >= 31 )
6394 {
6395
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.family,f,true))
6396 {
6397 return qe_invalid;
6398 }
6399 256 }
6400 else
6401 {
6402
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_getc(&tempitem.family,f,true))
6403 {
6404 return qe_invalid;
6405 }
6406 }
6407
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 16)
6408 if(tempitem.family == 0xFF)
6409 tempitem.family = itype_misc;
6410
6411
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.fam_type,f,true))
6412 {
6413 return qe_invalid;
6414 }
6415
6416
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version>5)
6417 {
6418
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if(s_version>=31)
6419 {
6420
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.power,f,true))
6421 {
6422 return qe_invalid;
6423 }
6424 256 }
6425 else
6426 {
6427
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_getc(&tempitem.power,f,true))
6428 {
6429 return qe_invalid;
6430 }
6431 }
6432
6433 //converted flags from 16b to 32b -Z
6434
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version < 41 )
6435 {
6436
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetw(&tempitem.flags,f,true))
6437 {
6438 return qe_invalid;
6439 }
6440 6144 }
6441 else
6442 {
6443
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.flags,f,true))
6444 {
6445 return qe_invalid;
6446 }
6447 }
6448 6400 }
6449 else
6450 {
6451 //tempitem.power = tempitem.fam_type;
6452 char tempchar;
6453
6454 if(!p_getc(&tempchar,f,true))
6455 {
6456 return qe_invalid;
6457 }
6458
6459 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6460 }
6461
6462
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetw(&tempitem.script,f,true))
6463 {
6464 return qe_invalid;
6465 }
6466
6467
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version<=3)
6468 {
6469 if(tempitem.script > NUMSCRIPTITEM)
6470 {
6471 tempitem.script = 0;
6472 }
6473 }
6474
6475
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.count,f,true))
6476 {
6477 return qe_invalid;
6478 }
6479
6480
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetw(&tempitem.amount,f,true))
6481 {
6482 return qe_invalid;
6483 }
6484
6485
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetw(&tempitem.collect_script,f,true))
6486 {
6487 return qe_invalid;
6488 }
6489
6490
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version<=3)
6491 {
6492 if(tempitem.collect_script > NUMSCRIPTITEM)
6493 {
6494 tempitem.collect_script = 0;
6495 }
6496 }
6497
6498
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetw(&tempitem.setmax,f,true))
6499 {
6500 return qe_invalid;
6501 }
6502
6503
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetw(&tempitem.max,f,true))
6504 {
6505 return qe_invalid;
6506 }
6507
6508
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.playsound,f,true))
6509 {
6510 return qe_invalid;
6511 }
6512
6513
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 6400 times.
57600 for(int32_t j=0; j<8; j++)
6514 {
6515
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&tempitem.initiald[j],f,true))
6516 {
6517 return qe_invalid;
6518 }
6519 51200 }
6520
6521
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 6400 times.
19200 for(int32_t j=0; j<2; j++)
6522 {
6523
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempitem.initiala[j],f,true))
6524 {
6525 return qe_invalid;
6526 }
6527 12800 }
6528
6529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(s_version>4)
6530 {
6531
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version>5)
6532 {
6533
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn,f,true))
6534 {
6535 return qe_invalid;
6536 }
6537
6538
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn2,f,true))
6539 {
6540 return qe_invalid;
6541 }
6542
6543
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn3,f,true))
6544 {
6545 return qe_invalid;
6546 }
6547
6548
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn4,f,true))
6549 {
6550 return qe_invalid;
6551 }
6552
6553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(s_version>=15)
6554 {
6555
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn5,f,true))
6556 {
6557 return qe_invalid;
6558 }
6559
6560
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn6,f,true))
6561 {
6562 return qe_invalid;
6563 }
6564
6565
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn7,f,true))
6566 {
6567 return qe_invalid;
6568 }
6569
6570
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn8,f,true))
6571 {
6572 return qe_invalid;
6573 }
6574
6575
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn9,f,true))
6576 {
6577 return qe_invalid;
6578 }
6579
6580
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.wpn10,f,true))
6581 {
6582 return qe_invalid;
6583 }
6584 6400 }
6585
6586
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.pickup_hearts,f,true))
6587 {
6588 return qe_invalid;
6589 }
6590
6591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(s_version<15)
6592 {
6593 if(!p_igetw(&dummy_word,f,true))
6594 {
6595 return qe_invalid;
6596 }
6597
6598 tempitem.misc1=dummy_word;
6599
6600 if(!p_igetw(&dummy_word,f,true))
6601 {
6602 return qe_invalid;
6603 }
6604
6605 tempitem.misc2=dummy_word;
6606 }
6607 else
6608 {
6609
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc1,f,true))
6610 {
6611 return qe_invalid;
6612 }
6613
6614
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc2,f,true))
6615 {
6616 return qe_invalid;
6617 }
6618
6619 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6620
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version<24)
6621 {
6622 if(tempitem.family==itype_shield)
6623 {
6624 tempitem.misc1|=shSCRIPT;
6625 }
6626 }
6627 }
6628
6629
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if(s_version < 53)
6630 {
6631 byte tempbyte;
6632
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_getc(&tempbyte,f,true))
6633 {
6634 return qe_invalid;
6635 }
6636 6144 tempitem.cost_amount[0] = tempbyte;
6637 6144 }
6638 else
6639 {
6640
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 256 times.
768 for(auto q = 0; q < 2; ++q)
6641 {
6642
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6643 {
6644 return qe_invalid;
6645 }
6646 512 }
6647 }
6648 6400 }
6649 else
6650 {
6651 char tempchar;
6652
6653 if(!p_getc(&tempchar,f,true))
6654 {
6655 return qe_invalid;
6656 }
6657
6658 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6659 }
6660
6661 // June 2007: more misc. attributes
6662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(s_version>=12)
6663 {
6664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(s_version<15)
6665 {
6666 if(!p_igetw(&dummy_word,f,true))
6667 {
6668 return qe_invalid;
6669 }
6670
6671 tempitem.misc3=dummy_word;
6672
6673 if(!p_igetw(&dummy_word,f,true))
6674 {
6675 return qe_invalid;
6676 }
6677
6678 tempitem.misc4=dummy_word;
6679 }
6680 else
6681 {
6682
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc3,f,true))
6683 {
6684 return qe_invalid;
6685 }
6686
6687
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc4,f,true))
6688 {
6689 return qe_invalid;
6690 }
6691
6692
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc5,f,true))
6693 {
6694 return qe_invalid;
6695 }
6696
6697
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc6,f,true))
6698 {
6699 return qe_invalid;
6700 }
6701
6702
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc7,f,true))
6703 {
6704 return qe_invalid;
6705 }
6706
6707
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc8,f,true))
6708 {
6709 return qe_invalid;
6710 }
6711
6712
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc9,f,true))
6713 {
6714 return qe_invalid;
6715 }
6716
6717
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.misc10,f,true))
6718 {
6719 return qe_invalid;
6720 }
6721 }
6722
6723
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempitem.usesound,f,true))
6724 {
6725 return qe_invalid;
6726 }
6727
6728
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if(s_version >= 49)
6729 {
6730
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&tempitem.usesound2,f,true))
6731 {
6732 return qe_invalid;
6733 }
6734 256 }
6735 6144 else tempitem.usesound2 = 0;
6736
6737
3/4
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 6144 times.
✗ Branch 3 not taken.
6400 if(s_version < 50 && tempitem.family == itype_mirror)
6738 {
6739 //Split continue/dmap warp effect/sfx, port for old
6740 tempitem.misc2 = tempitem.misc1;
6741 tempitem.usesound2 = tempitem.usesound;
6742 }
6743 6400 }
6744 6400 }
6745
6746
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6747 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6748
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&tempitem.useweapon,f,true))
6749 {
6750 return qe_invalid;
6751 }
6752
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&tempitem.usedefence,f,true))
6753 {
6754 return qe_invalid;
6755 }
6756
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weaprange,f,true))
6757 {
6758 return qe_invalid;
6759 }
6760
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weapduration,f,true))
6761 {
6762 return qe_invalid;
6763 }
6764
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 256 times.
2816 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6765 {
6766
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6767 {
6768 return qe_invalid;
6769 }
6770 2560 }
6771 256 }
6772
6773
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6774 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6775
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.duplicates,f,true))
6776 {
6777 return qe_invalid;
6778 }
6779
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 256 times.
2304 for ( int32_t q = 0; q < INITIAL_D; q++ )
6780 {
6781
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6782 {
6783 return qe_invalid;
6784 }
6785 2048 }
6786
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 256 times.
768 for ( int32_t q = 0; q < INITIAL_A; q++ )
6787 {
6788
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6789 {
6790 return qe_invalid;
6791 }
6792 512 }
6793
6794
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&tempitem.drawlayer,f,true))
6795 {
6796 return qe_invalid;
6797 }
6798
6799
6800
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.hxofs,f,true))
6801 {
6802 return qe_invalid;
6803 }
6804
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.hyofs,f,true))
6805 {
6806 return qe_invalid;
6807 }
6808
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.hxsz,f,true))
6809 {
6810 return qe_invalid;
6811 }
6812
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.hysz,f,true))
6813 {
6814 return qe_invalid;
6815 }
6816
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.hzsz,f,true))
6817 {
6818 return qe_invalid;
6819 }
6820
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.xofs,f,true))
6821 {
6822 return qe_invalid;
6823 }
6824
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.yofs,f,true))
6825 {
6826 return qe_invalid;
6827 }
6828
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6829 {
6830 return qe_invalid;
6831 }
6832
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6833 {
6834 return qe_invalid;
6835 }
6836
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6837 {
6838 return qe_invalid;
6839 }
6840
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weap_hysz,f,true))
6841 {
6842 return qe_invalid;
6843 }
6844
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6845 {
6846 return qe_invalid;
6847 }
6848
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weap_xofs,f,true))
6849 {
6850 return qe_invalid;
6851 }
6852
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weap_yofs,f,true))
6853 {
6854 return qe_invalid;
6855 }
6856
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetw(&tempitem.weaponscript,f,true))
6857 {
6858 return qe_invalid;
6859 }
6860
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.wpnsprite,f,true))
6861 {
6862 return qe_invalid;
6863 }
6864 256 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6865
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 256 times.
768 for(auto q = 0; q < num_cost_tmr; ++q)
6866 {
6867
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6868 {
6869 return qe_invalid;
6870 }
6871 512 }
6872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
256 for(auto q = num_cost_tmr; q < 2; ++q)
6873 tempitem.magiccosttimer[q] = 0;
6874 256 }
6875
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6876 {
6877 //Item Size FLags, TileWidth, TileHeight
6878
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6879 {
6880 return qe_invalid;
6881 }
6882
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.tilew,f,true))
6883 {
6884 return qe_invalid;
6885 }
6886
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.tileh,f,true))
6887 {
6888 return qe_invalid;
6889 }
6890 256 }
6891
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 29 ) //! More new vars.
6892 {
6893 //Item Size FLags, TileWidth, TileHeight
6894
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6895 {
6896 return qe_invalid;
6897 }
6898
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weap_tilew,f,true))
6899 {
6900 return qe_invalid;
6901 }
6902
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.weap_tileh,f,true))
6903 {
6904 return qe_invalid;
6905 }
6906 256 }
6907
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 30 ) //! More new vars.
6908 {
6909 //Pickup Type
6910
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempitem.pickup,f,true))
6911 {
6912 return qe_invalid;
6913 }
6914 256 }
6915
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 32 ) //! More new vars.
6916 {
6917 //Pickup Type
6918
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetw(&tempitem.pstring,f,true))
6919 {
6920 return qe_invalid;
6921 }
6922 256 }
6923
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 33 ) //! More new vars.
6924 {
6925 //Pickup Type
6926
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
6927 {
6928 return qe_invalid;
6929 }
6930 256 }
6931
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 34 ) //! cost counter
6932 {
6933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
256 if(s_version < 53)
6934 {
6935 if(!p_getc(&tempitem.cost_counter[0],f,true))
6936 {
6937 return qe_invalid;
6938 }
6939 }
6940 else
6941 {
6942
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 256 times.
768 for(auto q = 0; q < 2; ++q)
6943 {
6944
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&tempitem.cost_counter[q],f,true))
6945 {
6946 return qe_invalid;
6947 }
6948 512 }
6949 }
6950 256 }
6951
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 44 ) //! sprite scripts
6952 {
6953
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 256 times.
2304 for ( int32_t q = 0; q < 8; q++ )
6954 {
6955
2/2
✓ Branch 0 taken 133120 times.
✓ Branch 1 taken 2048 times.
135168 for ( int32_t w = 0; w < 65; w++ )
6956 {
6957
1/2
✓ Branch 0 taken 133120 times.
✗ Branch 1 not taken.
133120 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
6958 {
6959 return qe_invalid;
6960 }
6961 133120 }
6962
2/2
✓ Branch 0 taken 133120 times.
✓ Branch 1 taken 2048 times.
135168 for ( int32_t w = 0; w < 65; w++ )
6963 {
6964
1/2
✓ Branch 0 taken 133120 times.
✗ Branch 1 not taken.
133120 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
6965 {
6966 return qe_invalid;
6967 }
6968 133120 }
6969
2/2
✓ Branch 0 taken 133120 times.
✓ Branch 1 taken 2048 times.
135168 for ( int32_t w = 0; w < 65; w++ )
6970 {
6971
1/2
✓ Branch 0 taken 133120 times.
✗ Branch 1 not taken.
133120 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
6972 {
6973 return qe_invalid;
6974 }
6975 133120 }
6976
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
6977 {
6978 return qe_invalid;
6979 }
6980
6981 2048 }
6982
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 256 times.
768 for ( int32_t q = 0; q < 2; q++ )
6983 {
6984
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
6985 {
6986 return qe_invalid;
6987 }
6988 512 }
6989 //Pickup Type
6990
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetw(&tempitem.sprite_script,f,true))
6991 {
6992 return qe_invalid;
6993 }
6994 256 }
6995
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 48 ) //! pickup flags
6996 {
6997
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
6998 {
6999 return qe_invalid;
7000 }
7001 256 }
7002 6400 }
7003 else
7004 {
7005 tempitem.count=-1;
7006 tempitem.family=itype_misc;
7007 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7008 tempitem.playsound=WAV_SCALE;
7009 reset_itembuf(&tempitem,i);
7010 }
7011
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if(s_version < 53)
7012 {
7013
4/4
✓ Branch 0 taken 6021 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 24 times.
6144 switch(tempitem.family)
7014 {
7015 case itype_arrow:
7016 72 tempitem.cost_counter[1] = crARROWS;
7017 72 tempitem.cost_amount[1] = 1;
7018 72 break;
7019 case itype_bomb:
7020 27 tempitem.cost_counter[1] = crBOMBS;
7021 27 tempitem.cost_amount[1] = 1;
7022 27 break;
7023 case itype_sbomb:
7024 24 tempitem.cost_counter[1] = crSBOMBS;
7025 24 tempitem.cost_amount[1] = 1;
7026 24 break;
7027 default:
7028 6021 tempitem.cost_counter[1] = crNONE;
7029 6021 tempitem.cost_amount[1] = 0;
7030 6021 }
7031 6144 tempitem.magiccosttimer[1] = 0;
7032 6144 }
7033
7034
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(keepdata==true)
7035 {
7036 6400 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7037 6400 }
7038 else if(zgpmode)
7039 {
7040 itemsbuf[i].tile=tempitem.tile;
7041 itemsbuf[i].misc_flags=tempitem.misc_flags;
7042 itemsbuf[i].csets=tempitem.csets;
7043 itemsbuf[i].frames=tempitem.frames;
7044 itemsbuf[i].speed=tempitem.speed;
7045 itemsbuf[i].delay=tempitem.delay;
7046 itemsbuf[i].ltm=tempitem.ltm;
7047 }
7048 6400 }
7049
7050 //////////////////////////////////////////////////////
7051 // Now do any updates because of new item additions
7052 // (These can't be done above because items_to_read
7053 // might be too low.)
7054 //////////////////////////////////////////////////////
7055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
7056 {
7057
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<MAXITEMS; i++)
7058 {
7059 6400 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7060
7061 //Account for older quests that didn't have an actual item for the used letter
7062
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6400 if(s_version < 2 && i==iLetterUsed)
7063 {
7064 reset_itembuf(&tempitem, iLetterUsed);
7065 strcpy(item_string[i],old_item_string[i]);
7066 tempitem.tile = itemsbuf[iLetter].tile;
7067 tempitem.csets = itemsbuf[iLetter].csets;
7068 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7069 tempitem.frames = itemsbuf[iLetter].frames;
7070 tempitem.speed = itemsbuf[iLetter].speed;
7071 tempitem.ltm = itemsbuf[iLetter].ltm;
7072 }
7073
7074
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 3)
7075 {
7076 switch(i)
7077 {
7078 case iRocsFeather:
7079 case iHoverBoots:
7080 case iSpinScroll:
7081 case iL2SpinScroll:
7082 case iCrossScroll:
7083 case iQuakeScroll:
7084 case iL2QuakeScroll:
7085 case iWhispRing:
7086 case iL2WhispRing:
7087 case iChargeRing:
7088 case iL2ChargeRing:
7089 case iPerilScroll:
7090 case iWalletL3:
7091 case iQuiverL4:
7092 case iBombBagL4:
7093 case iBracelet:
7094 case iL2Bracelet:
7095 case iOldGlove:
7096 case iL2Ladder:
7097 case iWealthMedal:
7098 case iL2WealthMedal:
7099 case iL3WealthMedal:
7100 reset_itembuf(&tempitem, i);
7101 strcpy(item_string[i],old_item_string[i]);
7102 break;
7103
7104 case iSShield:
7105 reset_itembuf(&tempitem, i);
7106 strcpy(item_string[i],old_item_string[i]);
7107 strcpy(item_string[iShield],old_item_string[iShield]);
7108 strcpy(item_string[iMShield],old_item_string[iMShield]);
7109 break;
7110 }
7111 }
7112
7113
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 5)
7114 {
7115 switch(i)
7116 {
7117 case iHeartRing:
7118 case iL2HeartRing:
7119 case iL3HeartRing:
7120 case iMagicRing:
7121 case iL2MagicRing:
7122 case iL3MagicRing:
7123 case iL4MagicRing:
7124 reset_itembuf(&tempitem, i);
7125 strcpy(item_string[i],old_item_string[i]);
7126 break;
7127 }
7128 }
7129
7130
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7131 {
7132 if(i!=iBPotion && i!=iRPotion)
7133 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7134
7135 switch(i)
7136 {
7137 case iTriforce:
7138 tempitem.fam_type=1;
7139 break;
7140
7141 case iBigTri:
7142 tempitem.fam_type=0;
7143 break;
7144
7145 case iBombs:
7146 tempitem.fam_type=i_bomb;
7147 tempitem.power=4;
7148 tempitem.wpn=wBOMB;
7149 tempitem.wpn2=wBOOM;
7150 tempitem.misc1 = 50;
7151
7152 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7153
7154 break;
7155
7156 case iSBomb:
7157 tempitem.fam_type=i_sbomb;
7158 tempitem.power=16;
7159 tempitem.wpn=wSBOMB;
7160 tempitem.wpn2=wSBOOM;
7161 tempitem.misc1 = 50;
7162
7163 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7164
7165 break;
7166
7167 case iBook:
7168 if(get_bit(deprecated_rules, 113))
7169 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7170
7171 break;
7172
7173 case iSArrow:
7174 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7175 tempitem.power=4;
7176 tempitem.flags|=ITEM_GAMEDATA;
7177 tempitem.wpn=wSARROW;
7178 break;
7179
7180 case iGArrow:
7181 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7182 tempitem.power=8;
7183 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7184 tempitem.wpn=wGARROW;
7185 break;
7186
7187 case iBrang:
7188 tempitem.power=0;
7189 tempitem.wpn=wBRANG;
7190 tempitem.misc1=36;
7191 break;
7192
7193 case iMBrang:
7194 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7195 tempitem.power=0;
7196 tempitem.wpn=wMBRANG;
7197 break;
7198
7199 case iFBrang:
7200 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7201 tempitem.power=2;
7202 tempitem.wpn=wFBRANG;
7203 break;
7204
7205 case iBoots:
7206 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7207 tempitem.power=7;
7208 break;
7209
7210 case iWand:
7211 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7212 tempitem.power=2;
7213 tempitem.wpn=wWAND;
7214 tempitem.wpn3=wMAGIC;
7215 break;
7216
7217 case iBCandle:
7218 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7219 tempitem.power=1;
7220 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7221 tempitem.wpn3=wFIRE;
7222 break;
7223
7224 case iRCandle:
7225 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7226 tempitem.power=1;
7227 tempitem.wpn3=wFIRE;
7228 break;
7229
7230 case iSword:
7231 tempitem.power=1;
7232 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7233 tempitem.wpn=tempitem.wpn3=wSWORD;
7234 tempitem.wpn2=wSWORDSLASH;
7235 break;
7236
7237 case iWSword:
7238 tempitem.power=2;
7239 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7240 tempitem.wpn=tempitem.wpn3=wWSWORD;
7241 tempitem.wpn2=wWSWORDSLASH;
7242 break;
7243
7244 case iMSword:
7245 tempitem.power=4;
7246 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7247 tempitem.wpn=tempitem.wpn3=wMSWORD;
7248 tempitem.wpn2=wMSWORDSLASH;
7249 break;
7250
7251 case iXSword:
7252 tempitem.power=8;
7253 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7254 tempitem.wpn=tempitem.wpn3=wXSWORD;
7255 tempitem.wpn2=wXSWORDSLASH;
7256 break;
7257
7258 case iNayrusLove:
7259 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7260 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7261 tempitem.wpn=wNAYRUSLOVE1A;
7262 tempitem.wpn2=wNAYRUSLOVE1B;
7263 tempitem.wpn3=wNAYRUSLOVES1A;
7264 tempitem.wpn4=wNAYRUSLOVES1B;
7265 tempitem.wpn6=wNAYRUSLOVE2A;
7266 tempitem.wpn7=wNAYRUSLOVE2B;
7267 tempitem.wpn8=wNAYRUSLOVES2A;
7268 tempitem.wpn9=wNAYRUSLOVES2B;
7269 tempitem.wpn5 = iwNayrusLoveShieldFront;
7270 tempitem.wpn10 = iwNayrusLoveShieldBack;
7271 tempitem.misc1=512;
7272 tempitem.cost_amount[0]=64;
7273 break;
7274
7275 case iLens:
7276 tempitem.misc1=60;
7277 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7278 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7279 break;
7280
7281 case iArrow:
7282 tempitem.power=2;
7283 tempitem.wpn=wARROW;
7284 break;
7285
7286 case iHoverBoots:
7287 tempitem.misc1=45;
7288 tempitem.wpn=iwHover;
7289 break;
7290
7291 case iDinsFire:
7292 tempitem.power=8;
7293 tempitem.wpn=wDINSFIRE1A;
7294 tempitem.wpn2=wDINSFIRE1B;
7295 tempitem.wpn3=wDINSFIRES1A;
7296 tempitem.wpn4=wDINSFIRES1B;
7297 tempitem.misc1 = 32;
7298 tempitem.misc2 = 200;
7299 tempitem.cost_amount[0]=32;
7300 break;
7301
7302 case iFaroresWind:
7303 tempitem.cost_amount[0]=32;
7304 break;
7305
7306 case iHookshot:
7307 tempitem.power=0;
7308 tempitem.flags&=~ITEM_FLAG1;
7309 tempitem.wpn=wHSHEAD;
7310 tempitem.wpn2=wHSCHAIN_H;
7311 tempitem.wpn4=wHSHANDLE;
7312 tempitem.wpn3=wHSCHAIN_V;
7313 tempitem.misc1=50;
7314 tempitem.misc2=100;
7315 break;
7316
7317 case iLongshot:
7318 tempitem.power=0;
7319 tempitem.flags&=~ITEM_FLAG1;
7320 tempitem.wpn=wLSHEAD;
7321 tempitem.wpn2=wLSCHAIN_H;
7322 tempitem.wpn4=wLSHANDLE;
7323 tempitem.wpn3=wLSCHAIN_V;
7324 tempitem.misc1=99;
7325 tempitem.misc2=100;
7326 break;
7327
7328 case iHammer:
7329 tempitem.power=4;
7330 tempitem.wpn=wHAMMER;
7331 tempitem.wpn2=iwHammerSmack;
7332 break;
7333
7334 case iCByrna:
7335 tempitem.power=1;
7336 tempitem.wpn=wCBYRNA;
7337 tempitem.wpn2=wCBYRNASLASH;
7338 tempitem.wpn3=wCBYRNAORB;
7339 tempitem.misc1=4;
7340 tempitem.misc2=16;
7341 tempitem.misc3=1;
7342 tempitem.cost_amount[0]=1;
7343 break;
7344
7345 case iWhistle:
7346 tempitem.wpn=wWIND;
7347 tempitem.misc1=3;
7348 tempitem.flags|=ITEM_FLAG1;
7349 break;
7350
7351 case iBRing:
7352 tempitem.power=2;
7353 tempitem.misc1=spBLUE;
7354 break;
7355
7356 case iRRing:
7357 tempitem.power=4;
7358 tempitem.misc1=spRED;
7359 break;
7360
7361 case iGRing:
7362 tempitem.power=8;
7363 tempitem.misc1=spGOLD;
7364 break;
7365
7366 case iSpinScroll:
7367 tempitem.power = 2;
7368 tempitem.misc1 = 1;
7369 break;
7370
7371 case iL2SpinScroll:
7372 tempitem.family=itype_spinscroll2;
7373 tempitem.fam_type=1;
7374 tempitem.cost_amount[0]=8;
7375 tempitem.power=2;
7376 tempitem.misc1 = 20;
7377 break;
7378
7379 case iQuakeScroll:
7380 tempitem.misc1=0x10;
7381 tempitem.misc2=64;
7382 break;
7383
7384 case iL2QuakeScroll:
7385 tempitem.family=itype_quakescroll2;
7386 tempitem.fam_type=1;
7387 tempitem.power = 2;
7388 tempitem.misc1=0x20;
7389 tempitem.misc2=192;
7390 tempitem.cost_amount[0]=8;
7391 break;
7392
7393 case iChargeRing:
7394 tempitem.misc1=64;
7395 tempitem.misc2=128;
7396 break;
7397
7398 case iL2ChargeRing:
7399 tempitem.misc1=32;
7400 tempitem.misc2=64;
7401 break;
7402
7403 case iOldGlove:
7404 tempitem.flags |= ITEM_FLAG1;
7405
7406 //fallthrough
7407 case iBombBagL4:
7408 case iWalletL3:
7409 case iQuiverL4:
7410 case iBracelet:
7411 tempitem.power = 1;
7412 break;
7413
7414 case iL2Bracelet:
7415 tempitem.power = 2;
7416 break;
7417
7418 case iMKey:
7419 tempitem.power=0xFF;
7420 tempitem.flags |= ITEM_FLAG1;
7421 break;
7422 }
7423 }
7424
7425
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 7)
7426 {
7427 switch(i)
7428 {
7429 case iStoneAgony:
7430 case iStompBoots:
7431 case iPerilRing:
7432 case iWhimsicalRing:
7433 {
7434 reset_itembuf(&tempitem, i);
7435 strcpy(item_string[i],old_item_string[i]);
7436 break;
7437 }
7438 }
7439 }
7440
7441
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 8) // May 2007: Some corrections.
7442 {
7443 switch(i)
7444 {
7445 case iMShield:
7446 tempitem.misc1|=shFLAME;
7447 tempitem.misc2|=shFIREBALL|shMAGIC;
7448
7449 if(get_bit(quest_rules, qr_SWORDMIRROR))
7450 {
7451 tempitem.misc2 |= shSWORD;
7452 }
7453
7454 // fallthrough
7455 case iShield:
7456 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7457
7458 // fallthrough
7459 case iSShield:
7460 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7461
7462 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7463 {
7464 tempitem.misc2 |= shROCK;
7465 }
7466
7467 break;
7468
7469 case iWhispRing:
7470 tempitem.power=1;
7471 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7472 tempitem.misc1 = 3;
7473 break;
7474
7475 case iL2WhispRing:
7476 tempitem.power=0;
7477 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7478 tempitem.misc1 = 3;
7479 break;
7480
7481 case iL2Ladder:
7482 case iBow:
7483 case iCByrna:
7484 tempitem.power = 1;
7485 break;
7486 }
7487 }
7488
7489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6400 if(s_version < 9 && i==iClock)
7490 {
7491 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7492 }
7493
7494 //add the misc flag for bomb
7495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6400 if(s_version < 10 && tempitem.family == itype_bomb)
7496 {
7497 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7498 }
7499
7500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6400 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7501 {
7502 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7503 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7504 }
7505
7506
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 12) // June 2007: More Misc. attributes.
7507 {
7508 switch(i)
7509 {
7510 case iFBrang:
7511 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7512
7513 //fallthrough
7514 case iMBrang:
7515 tempitem.misc3 |= shSWORD|shMAGIC;
7516
7517 //fallthrough
7518 case iHookshot:
7519 case iLongshot:
7520 //fallthrough
7521 tempitem.misc3 |= shFIREBALL;
7522
7523 case iBrang:
7524 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7525 break;
7526 }
7527
7528 switch(tempitem.family)
7529 {
7530 case itype_hoverboots:
7531 tempitem.usesound = WAV_ZN1HOVER;
7532 break;
7533
7534 case itype_wand:
7535 case itype_book:
7536 tempitem.usesound = WAV_WAND;
7537 break;
7538
7539 case itype_arrow:
7540 tempitem.usesound = WAV_ARROW;
7541 break;
7542
7543 case itype_hookshot:
7544 tempitem.usesound = WAV_HOOKSHOT;
7545 break;
7546
7547 case itype_brang:
7548 tempitem.usesound = WAV_BRANG;
7549 break;
7550
7551 case itype_shield:
7552 tempitem.usesound = WAV_CHINK;
7553 break;
7554
7555 case itype_sword:
7556 tempitem.usesound = WAV_SWORD;
7557 break;
7558
7559 case itype_whistle:
7560 tempitem.usesound = WAV_WHISTLE;
7561 break;
7562
7563 case itype_hammer:
7564 tempitem.usesound = WAV_HAMMER;
7565 break;
7566
7567 case itype_dinsfire:
7568 tempitem.usesound = WAV_ZN1DINSFIRE;
7569 break;
7570
7571 case itype_faroreswind:
7572 tempitem.usesound = WAV_ZN1FARORESWIND;
7573 break;
7574
7575 case itype_nayruslove:
7576 tempitem.usesound = WAV_ZN1NAYRUSLOVE1;
7577 break;
7578
7579 case itype_bomb:
7580 case itype_sbomb:
7581 case itype_quakescroll:
7582 case itype_quakescroll2:
7583 tempitem.usesound = WAV_BOMB;
7584 break;
7585
7586 case itype_spinscroll:
7587 case itype_spinscroll2:
7588 tempitem.usesound = WAV_ZN1SPINATTACK;
7589 break;
7590 }
7591 }
7592
7593
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 13) // July 2007
7594 {
7595 if(tempitem.family == itype_whistle)
7596 {
7597 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7598 tempitem.power = 1;
7599 tempitem.flags|=ITEM_FLAG1;
7600 }
7601 else if(tempitem.family == itype_wand)
7602 tempitem.flags|=ITEM_FLAG1;
7603 else if(tempitem.family == itype_book)
7604 {
7605 tempitem.flags|=ITEM_FLAG1;
7606 tempitem.power = 2;
7607 }
7608 }
7609
7610
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 14) // August 2007
7611 {
7612 if(tempitem.family == itype_fairy)
7613 {
7614 tempitem.usesound = WAV_SCALE;
7615
7616 if(tempitem.fam_type)
7617 tempitem.misc3=50;
7618 }
7619 else if(tempitem.family == itype_potion)
7620 {
7621 tempitem.flags |= ITEM_GAINOLD;
7622 }
7623 }
7624
7625
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 17) // November 2007
7626 {
7627 if(tempitem.family == itype_candle && !tempitem.wpn3)
7628 {
7629 tempitem.wpn3 = wFIRE;
7630 }
7631 else if(tempitem.family == itype_arrow && tempitem.power>4)
7632 {
7633 tempitem.flags|=ITEM_FLAG1;
7634 }
7635 }
7636
7637
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 18) // New Year's Eve 2007
7638 {
7639 if(tempitem.family == itype_whistle)
7640 tempitem.misc2 = 8; // Use the Whistle warp ring
7641 else if(tempitem.family == itype_bait)
7642 tempitem.misc1 = 768; // Frames until it goes
7643 else if(tempitem.family == itype_triforcepiece)
7644 {
7645 if(tempitem.flags & ITEM_GAMEDATA)
7646 {
7647 tempitem.misc2 = 1; // Cutscene 1
7648 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7649 }
7650 }
7651 }
7652
7653
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 19) // January 2008
7654 {
7655 if(tempitem.family == itype_nayruslove)
7656 {
7657 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7658 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7659 }
7660 }
7661
7662
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 20) // October 2008
7663 {
7664 if(tempitem.family == itype_nayruslove)
7665 {
7666 tempitem.wpn6=wNAYRUSLOVE2A;
7667 tempitem.wpn7=wNAYRUSLOVE2B;
7668 tempitem.wpn8=wNAYRUSLOVES2A;
7669 tempitem.wpn9=wNAYRUSLOVES2B;
7670 tempitem.wpn5 = iwNayrusLoveShieldFront;
7671 tempitem.wpn10 = iwNayrusLoveShieldBack;
7672 }
7673 }
7674
7675
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 21) // November 2008
7676 {
7677 if(tempitem.flags & 0x0100) // ITEM_SLASH
7678 {
7679 tempitem.flags &= ~0x0100;
7680
7681 if(tempitem.family == itype_sword ||
7682 tempitem.family == itype_wand ||
7683 tempitem.family == itype_candle ||
7684 tempitem.family == itype_cbyrna)
7685 {
7686 tempitem.flags |= ITEM_FLAG4;
7687 }
7688 }
7689 }
7690
7691
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 22) // September 2009
7692 {
7693 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7694 {
7695 tempitem.misc3 = tempitem.power/2;
7696 }
7697 }
7698
7699
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 23) // March 2011
7700 {
7701 if(tempitem.family == itype_dinsfire)
7702 tempitem.wpn5 = wFIRE;
7703 else if(tempitem.family == itype_book)
7704 tempitem.wpn2 = wFIRE;
7705 }
7706
7707 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7708 // whether it was or not, and a lot of existing quests depended on the
7709 // incorrect behavior.
7710
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 25) // January 2012
7711 {
7712 if(tempitem.family == itype_bombbag)
7713 tempitem.flags |= 16;
7714
7715 if(tempitem.family == itype_dinsfire)
7716 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7717 }
7718
7719
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7720 {
7721
60/60
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 252 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 298 times.
✓ Branch 4 taken 770 times.
✓ Branch 5 taken 1377 times.
✓ Branch 6 taken 72 times.
✓ Branch 7 taken 72 times.
✓ Branch 8 taken 58 times.
✓ Branch 9 taken 38 times.
✓ Branch 10 taken 24 times.
✓ Branch 11 taken 48 times.
✓ Branch 12 taken 48 times.
✓ Branch 13 taken 27 times.
✓ Branch 14 taken 72 times.
✓ Branch 15 taken 72 times.
✓ Branch 16 taken 48 times.
✓ Branch 17 taken 72 times.
✓ Branch 18 taken 48 times.
✓ Branch 19 taken 24 times.
✓ Branch 20 taken 48 times.
✓ Branch 21 taken 27 times.
✓ Branch 22 taken 24 times.
✓ Branch 23 taken 72 times.
✓ Branch 24 taken 24 times.
✓ Branch 25 taken 24 times.
✓ Branch 26 taken 48 times.
✓ Branch 27 taken 24 times.
✓ Branch 28 taken 24 times.
✓ Branch 29 taken 24 times.
✓ Branch 30 taken 24 times.
✓ Branch 31 taken 24 times.
✓ Branch 32 taken 27 times.
✓ Branch 33 taken 24 times.
✓ Branch 34 taken 24 times.
✓ Branch 35 taken 24 times.
✓ Branch 36 taken 24 times.
✓ Branch 37 taken 48 times.
✓ Branch 38 taken 96 times.
✓ Branch 39 taken 24 times.
✓ Branch 40 taken 24 times.
✓ Branch 41 taken 46 times.
✓ Branch 42 taken 96 times.
✓ Branch 43 taken 24 times.
✓ Branch 44 taken 24 times.
✓ Branch 45 taken 24 times.
✓ Branch 46 taken 24 times.
✓ Branch 47 taken 24 times.
✓ Branch 48 taken 48 times.
✓ Branch 49 taken 48 times.
✓ Branch 50 taken 24 times.
✓ Branch 51 taken 72 times.
✓ Branch 52 taken 72 times.
✓ Branch 53 taken 96 times.
✓ Branch 54 taken 24 times.
✓ Branch 55 taken 24 times.
✓ Branch 56 taken 24 times.
✓ Branch 57 taken 24 times.
✓ Branch 58 taken 24 times.
✓ Branch 59 taken 24 times.
6144 switch(tempitem.family)
7722 {
7723 case itype_sword:
7724 {
7725 1377 tempitem.flags &= ~(ITEM_FLAG5);
7726 1377 tempitem.misc3 = 0;
7727 1377 tempitem.misc4 = 0;
7728 1377 tempitem.misc5 = 0;
7729 1377 tempitem.misc6 = 0;
7730 1377 tempitem.misc7 = 0;
7731 1377 tempitem.misc8 = 0;
7732 1377 tempitem.misc9 = 0;
7733 1377 tempitem.misc10 = 0;
7734 1377 tempitem.wpn4 = 0;
7735 1377 tempitem.wpn5 = 0;
7736 1377 tempitem.wpn6 = 0;
7737 1377 tempitem.wpn7 = 0;
7738 1377 tempitem.wpn8 = 0;
7739 1377 tempitem.wpn9 = 0;
7740 1377 tempitem.wpn10 = 0;
7741 1377 break;
7742 }
7743 case itype_brang:
7744 {
7745 72 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7746 72 tempitem.misc2 = 0;
7747 72 tempitem.misc5 = 0;
7748 72 tempitem.misc6 = 0;
7749 72 tempitem.misc7 = 0;
7750 72 tempitem.misc8 = 0;
7751 72 tempitem.misc9 = 0;
7752 72 tempitem.misc10 = 0;
7753 72 tempitem.wpn4 = 0;
7754 72 tempitem.wpn5 = 0;
7755 72 tempitem.wpn6 = 0;
7756 72 tempitem.wpn7 = 0;
7757 72 tempitem.wpn8 = 0;
7758 72 tempitem.wpn9 = 0;
7759 72 tempitem.wpn10 = 0;
7760 72 break;
7761 }
7762 case itype_arrow:
7763 {
7764 72 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7765 72 tempitem.misc2 = 0;
7766 72 tempitem.misc3 = 0;
7767 72 tempitem.misc4 = 0;
7768 72 tempitem.misc5 = 0;
7769 72 tempitem.misc6 = 0;
7770 72 tempitem.misc7 = 0;
7771 72 tempitem.misc8 = 0;
7772 72 tempitem.misc9 = 0;
7773 72 tempitem.misc10 = 0;
7774 72 tempitem.wpn4 = 0;
7775 72 tempitem.wpn5 = 0;
7776 72 tempitem.wpn6 = 0;
7777 72 tempitem.wpn7 = 0;
7778 72 tempitem.wpn8 = 0;
7779 72 tempitem.wpn9 = 0;
7780 72 tempitem.wpn10 = 0;
7781 72 break;
7782 }
7783 case itype_candle:
7784 {
7785 58 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7786 58 tempitem.misc1 = 0;
7787 58 tempitem.misc2 = 0;
7788 58 tempitem.misc3 = 0;
7789 58 tempitem.misc4 = 0;
7790 58 tempitem.misc5 = 0;
7791 58 tempitem.misc6 = 0;
7792 58 tempitem.misc7 = 0;
7793 58 tempitem.misc8 = 0;
7794 58 tempitem.misc9 = 0;
7795 58 tempitem.misc10 = 0;
7796 58 tempitem.wpn4 = 0;
7797 58 tempitem.wpn5 = 0;
7798 58 tempitem.wpn6 = 0;
7799 58 tempitem.wpn7 = 0;
7800 58 tempitem.wpn8 = 0;
7801 58 tempitem.wpn9 = 0;
7802 58 tempitem.wpn10 = 0;
7803 58 break;
7804 }
7805 case itype_whistle:
7806 {
7807 38 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7808 38 tempitem.misc3 = 0;
7809 38 tempitem.misc4 = 0;
7810 38 tempitem.misc5 = 0;
7811 38 tempitem.misc6 = 0;
7812 38 tempitem.misc7 = 0;
7813 38 tempitem.misc8 = 0;
7814 38 tempitem.misc9 = 0;
7815 38 tempitem.misc10 = 0;
7816 38 tempitem.wpn2 = 0;
7817 38 tempitem.wpn3 = 0;
7818 38 tempitem.wpn4 = 0;
7819 38 tempitem.wpn5 = 0;
7820 38 tempitem.wpn6 = 0;
7821 38 tempitem.wpn7 = 0;
7822 38 tempitem.wpn8 = 0;
7823 38 tempitem.wpn9 = 0;
7824 38 tempitem.wpn10 = 0;
7825 38 break;
7826 }
7827 case itype_bait:
7828 {
7829 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7830 24 tempitem.misc2 = 0;
7831 24 tempitem.misc3 = 0;
7832 24 tempitem.misc4 = 0;
7833 24 tempitem.misc5 = 0;
7834 24 tempitem.misc6 = 0;
7835 24 tempitem.misc7 = 0;
7836 24 tempitem.misc8 = 0;
7837 24 tempitem.misc9 = 0;
7838 24 tempitem.misc10 = 0;
7839 24 tempitem.wpn2 = 0;
7840 24 tempitem.wpn3 = 0;
7841 24 tempitem.wpn4 = 0;
7842 24 tempitem.wpn5 = 0;
7843 24 tempitem.wpn6 = 0;
7844 24 tempitem.wpn7 = 0;
7845 24 tempitem.wpn8 = 0;
7846 24 tempitem.wpn9 = 0;
7847 24 tempitem.wpn10 = 0;
7848 24 break;
7849 }
7850 case itype_letter:
7851 {
7852 48 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7853 48 tempitem.misc1 = 0;
7854 48 tempitem.misc2 = 0;
7855 48 tempitem.misc3 = 0;
7856 48 tempitem.misc4 = 0;
7857 48 tempitem.misc5 = 0;
7858 48 tempitem.misc6 = 0;
7859 48 tempitem.misc7 = 0;
7860 48 tempitem.misc8 = 0;
7861 48 tempitem.misc9 = 0;
7862 48 tempitem.misc10 = 0;
7863 48 tempitem.wpn = 0;
7864 48 tempitem.wpn2 = 0;
7865 48 tempitem.wpn3 = 0;
7866 48 tempitem.wpn4 = 0;
7867 48 tempitem.wpn5 = 0;
7868 48 tempitem.wpn6 = 0;
7869 48 tempitem.wpn7 = 0;
7870 48 tempitem.wpn8 = 0;
7871 48 tempitem.wpn9 = 0;
7872 48 tempitem.wpn10 = 0;
7873 48 break;
7874 }
7875 case itype_potion:
7876 {
7877 48 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7878 48 tempitem.misc3 = 0;
7879 48 tempitem.misc4 = 0;
7880 48 tempitem.misc5 = 0;
7881 48 tempitem.misc6 = 0;
7882 48 tempitem.misc7 = 0;
7883 48 tempitem.misc8 = 0;
7884 48 tempitem.misc9 = 0;
7885 48 tempitem.misc10 = 0;
7886 48 tempitem.wpn = 0;
7887 48 tempitem.wpn2 = 0;
7888 48 tempitem.wpn3 = 0;
7889 48 tempitem.wpn4 = 0;
7890 48 tempitem.wpn5 = 0;
7891 48 tempitem.wpn6 = 0;
7892 48 tempitem.wpn7 = 0;
7893 48 tempitem.wpn8 = 0;
7894 48 tempitem.wpn9 = 0;
7895 48 tempitem.wpn10 = 0;
7896 48 break;
7897 }
7898 case itype_wand:
7899 {
7900 27 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7901 27 tempitem.misc1 = 0;
7902 27 tempitem.misc2 = 0;
7903 27 tempitem.misc3 = 0;
7904 27 tempitem.misc4 = 0;
7905 27 tempitem.misc5 = 0;
7906 27 tempitem.misc6 = 0;
7907 27 tempitem.misc7 = 0;
7908 27 tempitem.misc8 = 0;
7909 27 tempitem.misc9 = 0;
7910 27 tempitem.misc10 = 0;
7911 27 tempitem.wpn4 = 0;
7912 27 tempitem.wpn5 = 0;
7913 27 tempitem.wpn6 = 0;
7914 27 tempitem.wpn7 = 0;
7915 27 tempitem.wpn8 = 0;
7916 27 tempitem.wpn9 = 0;
7917 27 tempitem.wpn10 = 0;
7918 27 break;
7919 }
7920 case itype_ring:
7921 {
7922 72 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7923 72 tempitem.misc2 = 0;
7924 72 tempitem.misc3 = 0;
7925 72 tempitem.misc4 = 0;
7926 72 tempitem.misc5 = 0;
7927 72 tempitem.misc6 = 0;
7928 72 tempitem.misc7 = 0;
7929 72 tempitem.misc8 = 0;
7930 72 tempitem.misc9 = 0;
7931 72 tempitem.misc10 = 0;
7932 72 tempitem.wpn = 0;
7933 72 tempitem.wpn2 = 0;
7934 72 tempitem.wpn3 = 0;
7935 72 tempitem.wpn4 = 0;
7936 72 tempitem.wpn5 = 0;
7937 72 tempitem.wpn6 = 0;
7938 72 tempitem.wpn7 = 0;
7939 72 tempitem.wpn8 = 0;
7940 72 tempitem.wpn9 = 0;
7941 72 tempitem.wpn10 = 0;
7942 72 break;
7943 }
7944 case itype_wallet:
7945 {
7946 72 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7947 72 tempitem.misc3 = 0;
7948 72 tempitem.misc4 = 0;
7949 72 tempitem.misc5 = 0;
7950 72 tempitem.misc6 = 0;
7951 72 tempitem.misc7 = 0;
7952 72 tempitem.misc8 = 0;
7953 72 tempitem.misc9 = 0;
7954 72 tempitem.misc10 = 0;
7955 72 tempitem.wpn = 0;
7956 72 tempitem.wpn2 = 0;
7957 72 tempitem.wpn3 = 0;
7958 72 tempitem.wpn4 = 0;
7959 72 tempitem.wpn5 = 0;
7960 72 tempitem.wpn6 = 0;
7961 72 tempitem.wpn7 = 0;
7962 72 tempitem.wpn8 = 0;
7963 72 tempitem.wpn9 = 0;
7964 72 tempitem.wpn10 = 0;
7965 72 break;
7966 }
7967 case itype_amulet:
7968 {
7969 48 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7970 48 tempitem.misc1 = 0;
7971 48 tempitem.misc2 = 0;
7972 48 tempitem.misc3 = 0;
7973 48 tempitem.misc4 = 0;
7974 48 tempitem.misc5 = 0;
7975 48 tempitem.misc6 = 0;
7976 48 tempitem.misc7 = 0;
7977 48 tempitem.misc8 = 0;
7978 48 tempitem.misc9 = 0;
7979 48 tempitem.misc10 = 0;
7980 48 tempitem.wpn = 0;
7981 48 tempitem.wpn2 = 0;
7982 48 tempitem.wpn3 = 0;
7983 48 tempitem.wpn4 = 0;
7984 48 tempitem.wpn5 = 0;
7985 48 tempitem.wpn6 = 0;
7986 48 tempitem.wpn7 = 0;
7987 48 tempitem.wpn8 = 0;
7988 48 tempitem.wpn9 = 0;
7989 48 tempitem.wpn10 = 0;
7990 48 break;
7991 }
7992 case itype_shield:
7993 {
7994 72 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7995 72 tempitem.misc3 = 0;
7996 72 tempitem.misc4 = 0;
7997 72 tempitem.misc5 = 0;
7998 72 tempitem.misc6 = 0;
7999 72 tempitem.misc7 = 0;
8000 72 tempitem.misc8 = 0;
8001 72 tempitem.misc9 = 0;
8002 72 tempitem.misc10 = 0;
8003 72 tempitem.wpn = 0;
8004 72 tempitem.wpn2 = 0;
8005 72 tempitem.wpn3 = 0;
8006 72 tempitem.wpn4 = 0;
8007 72 tempitem.wpn5 = 0;
8008 72 tempitem.wpn6 = 0;
8009 72 tempitem.wpn7 = 0;
8010 72 tempitem.wpn8 = 0;
8011 72 tempitem.wpn9 = 0;
8012 72 tempitem.wpn10 = 0;
8013 72 break;
8014 }
8015 case itype_bow:
8016 {
8017 48 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8018 48 tempitem.misc1 = 0;
8019 48 tempitem.misc2 = 0;
8020 48 tempitem.misc3 = 0;
8021 48 tempitem.misc4 = 0;
8022 48 tempitem.misc5 = 0;
8023 48 tempitem.misc6 = 0;
8024 48 tempitem.misc7 = 0;
8025 48 tempitem.misc8 = 0;
8026 48 tempitem.misc9 = 0;
8027 48 tempitem.misc10 = 0;
8028 48 tempitem.wpn = 0;
8029 48 tempitem.wpn2 = 0;
8030 48 tempitem.wpn3 = 0;
8031 48 tempitem.wpn4 = 0;
8032 48 tempitem.wpn5 = 0;
8033 48 tempitem.wpn6 = 0;
8034 48 tempitem.wpn7 = 0;
8035 48 tempitem.wpn8 = 0;
8036 48 tempitem.wpn9 = 0;
8037 48 tempitem.wpn10 = 0;
8038 48 break;
8039 }
8040 case itype_raft:
8041 {
8042 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8043 24 tempitem.misc1 = 0;
8044 24 tempitem.misc2 = 0;
8045 24 tempitem.misc3 = 0;
8046 24 tempitem.misc4 = 0;
8047 24 tempitem.misc5 = 0;
8048 24 tempitem.misc6 = 0;
8049 24 tempitem.misc7 = 0;
8050 24 tempitem.misc8 = 0;
8051 24 tempitem.misc9 = 0;
8052 24 tempitem.misc10 = 0;
8053 24 tempitem.wpn = 0;
8054 24 tempitem.wpn2 = 0;
8055 24 tempitem.wpn3 = 0;
8056 24 tempitem.wpn4 = 0;
8057 24 tempitem.wpn5 = 0;
8058 24 tempitem.wpn6 = 0;
8059 24 tempitem.wpn7 = 0;
8060 24 tempitem.wpn8 = 0;
8061 24 tempitem.wpn9 = 0;
8062 24 tempitem.wpn10 = 0;
8063 24 break;
8064 }
8065 case itype_ladder:
8066 {
8067 48 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8068 48 tempitem.misc1 = 0;
8069 48 tempitem.misc2 = 0;
8070 48 tempitem.misc3 = 0;
8071 48 tempitem.misc4 = 0;
8072 48 tempitem.misc5 = 0;
8073 48 tempitem.misc6 = 0;
8074 48 tempitem.misc7 = 0;
8075 48 tempitem.misc8 = 0;
8076 48 tempitem.misc9 = 0;
8077 48 tempitem.misc10 = 0;
8078 48 tempitem.wpn = 0;
8079 48 tempitem.wpn2 = 0;
8080 48 tempitem.wpn3 = 0;
8081 48 tempitem.wpn4 = 0;
8082 48 tempitem.wpn5 = 0;
8083 48 tempitem.wpn6 = 0;
8084 48 tempitem.wpn7 = 0;
8085 48 tempitem.wpn8 = 0;
8086 48 tempitem.wpn9 = 0;
8087 48 tempitem.wpn10 = 0;
8088 48 break;
8089 }
8090 case itype_book:
8091 {
8092 27 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8093 27 tempitem.misc1 = 0;
8094 27 tempitem.misc2 = 0;
8095 27 tempitem.misc3 = 0;
8096 27 tempitem.misc4 = 0;
8097 27 tempitem.misc5 = 0;
8098 27 tempitem.misc6 = 0;
8099 27 tempitem.misc7 = 0;
8100 27 tempitem.misc8 = 0;
8101 27 tempitem.misc9 = 0;
8102 27 tempitem.misc10 = 0;
8103 27 tempitem.wpn3 = 0;
8104 27 tempitem.wpn4 = 0;
8105 27 tempitem.wpn5 = 0;
8106 27 tempitem.wpn6 = 0;
8107 27 tempitem.wpn7 = 0;
8108 27 tempitem.wpn8 = 0;
8109 27 tempitem.wpn9 = 0;
8110 27 tempitem.wpn10 = 0;
8111 27 break;
8112 }
8113 case itype_magickey:
8114 {
8115 24 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8116 24 tempitem.misc1 = 0;
8117 24 tempitem.misc2 = 0;
8118 24 tempitem.misc3 = 0;
8119 24 tempitem.misc4 = 0;
8120 24 tempitem.misc5 = 0;
8121 24 tempitem.misc6 = 0;
8122 24 tempitem.misc7 = 0;
8123 24 tempitem.misc8 = 0;
8124 24 tempitem.misc9 = 0;
8125 24 tempitem.misc10 = 0;
8126 24 tempitem.wpn = 0;
8127 24 tempitem.wpn2 = 0;
8128 24 tempitem.wpn3 = 0;
8129 24 tempitem.wpn4 = 0;
8130 24 tempitem.wpn5 = 0;
8131 24 tempitem.wpn6 = 0;
8132 24 tempitem.wpn7 = 0;
8133 24 tempitem.wpn8 = 0;
8134 24 tempitem.wpn9 = 0;
8135 24 tempitem.wpn10 = 0;
8136 24 break;
8137 }
8138 case itype_bracelet:
8139 {
8140 72 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8141 72 tempitem.misc1 = 0;
8142 72 tempitem.misc2 = 0;
8143 72 tempitem.misc3 = 0;
8144 72 tempitem.misc4 = 0;
8145 72 tempitem.misc5 = 0;
8146 72 tempitem.misc6 = 0;
8147 72 tempitem.misc7 = 0;
8148 72 tempitem.misc8 = 0;
8149 72 tempitem.misc9 = 0;
8150 72 tempitem.misc10 = 0;
8151 72 tempitem.wpn = 0;
8152 72 tempitem.wpn2 = 0;
8153 72 tempitem.wpn3 = 0;
8154 72 tempitem.wpn4 = 0;
8155 72 tempitem.wpn5 = 0;
8156 72 tempitem.wpn6 = 0;
8157 72 tempitem.wpn7 = 0;
8158 72 tempitem.wpn8 = 0;
8159 72 tempitem.wpn9 = 0;
8160 72 tempitem.wpn10 = 0;
8161 72 break;
8162 }
8163 case itype_flippers:
8164 {
8165 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8166 24 tempitem.misc1 = 0;
8167 24 tempitem.misc2 = 0;
8168 24 tempitem.misc3 = 0;
8169 24 tempitem.misc4 = 0;
8170 24 tempitem.misc5 = 0;
8171 24 tempitem.misc6 = 0;
8172 24 tempitem.misc7 = 0;
8173 24 tempitem.misc8 = 0;
8174 24 tempitem.misc9 = 0;
8175 24 tempitem.misc10 = 0;
8176 24 tempitem.wpn = 0;
8177 24 tempitem.wpn2 = 0;
8178 24 tempitem.wpn3 = 0;
8179 24 tempitem.wpn4 = 0;
8180 24 tempitem.wpn5 = 0;
8181 24 tempitem.wpn6 = 0;
8182 24 tempitem.wpn7 = 0;
8183 24 tempitem.wpn8 = 0;
8184 24 tempitem.wpn9 = 0;
8185 24 tempitem.wpn10 = 0;
8186 24 break;
8187 }
8188 case itype_boots:
8189 {
8190 24 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8191 24 tempitem.misc1 = 0;
8192 24 tempitem.misc2 = 0;
8193 24 tempitem.misc3 = 0;
8194 24 tempitem.misc4 = 0;
8195 24 tempitem.misc5 = 0;
8196 24 tempitem.misc6 = 0;
8197 24 tempitem.misc7 = 0;
8198 24 tempitem.misc8 = 0;
8199 24 tempitem.misc9 = 0;
8200 24 tempitem.misc10 = 0;
8201 24 tempitem.wpn = 0;
8202 24 tempitem.wpn2 = 0;
8203 24 tempitem.wpn3 = 0;
8204 24 tempitem.wpn4 = 0;
8205 24 tempitem.wpn5 = 0;
8206 24 tempitem.wpn6 = 0;
8207 24 tempitem.wpn7 = 0;
8208 24 tempitem.wpn8 = 0;
8209 24 tempitem.wpn9 = 0;
8210 24 tempitem.wpn10 = 0;
8211 24 break;
8212 }
8213 case itype_hookshot:
8214 {
8215 48 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8216 48 tempitem.misc5 = 0;
8217 48 tempitem.misc6 = 0;
8218 48 tempitem.misc7 = 0;
8219 48 tempitem.misc8 = 0;
8220 48 tempitem.misc9 = 0;
8221 48 tempitem.misc10 = 0;
8222 48 tempitem.wpn5 = 0;
8223 48 tempitem.wpn6 = 0;
8224 48 tempitem.wpn7 = 0;
8225 48 tempitem.wpn8 = 0;
8226 48 tempitem.wpn9 = 0;
8227 48 tempitem.wpn10 = 0;
8228 48 break;
8229 }
8230 case itype_lens:
8231 {
8232 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8233 24 tempitem.misc2 = 0;
8234 24 tempitem.misc3 = 0;
8235 24 tempitem.misc4 = 0;
8236 24 tempitem.misc5 = 0;
8237 24 tempitem.misc6 = 0;
8238 24 tempitem.misc7 = 0;
8239 24 tempitem.misc8 = 0;
8240 24 tempitem.misc9 = 0;
8241 24 tempitem.misc10 = 0;
8242 24 tempitem.wpn = 0;
8243 24 tempitem.wpn2 = 0;
8244 24 tempitem.wpn3 = 0;
8245 24 tempitem.wpn4 = 0;
8246 24 tempitem.wpn5 = 0;
8247 24 tempitem.wpn6 = 0;
8248 24 tempitem.wpn7 = 0;
8249 24 tempitem.wpn8 = 0;
8250 24 tempitem.wpn9 = 0;
8251 24 tempitem.wpn10 = 0;
8252 24 break;
8253 }
8254 case itype_hammer:
8255 {
8256 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8257 24 tempitem.misc1 = 0;
8258 24 tempitem.misc2 = 0;
8259 24 tempitem.misc3 = 0;
8260 24 tempitem.misc4 = 0;
8261 24 tempitem.misc5 = 0;
8262 24 tempitem.misc6 = 0;
8263 24 tempitem.misc7 = 0;
8264 24 tempitem.misc8 = 0;
8265 24 tempitem.misc9 = 0;
8266 24 tempitem.misc10 = 0;
8267 24 tempitem.wpn3 = 0;
8268 24 tempitem.wpn4 = 0;
8269 24 tempitem.wpn5 = 0;
8270 24 tempitem.wpn6 = 0;
8271 24 tempitem.wpn7 = 0;
8272 24 tempitem.wpn8 = 0;
8273 24 tempitem.wpn9 = 0;
8274 24 tempitem.wpn10 = 0;
8275 24 break;
8276 }
8277 case itype_dinsfire:
8278 {
8279 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8280 24 tempitem.misc3 = 0;
8281 24 tempitem.misc4 = 0;
8282 24 tempitem.misc5 = 0;
8283 24 tempitem.misc6 = 0;
8284 24 tempitem.misc7 = 0;
8285 24 tempitem.misc8 = 0;
8286 24 tempitem.misc9 = 0;
8287 24 tempitem.misc10 = 0;
8288 24 tempitem.wpn6 = 0;
8289 24 tempitem.wpn7 = 0;
8290 24 tempitem.wpn8 = 0;
8291 24 tempitem.wpn9 = 0;
8292 24 tempitem.wpn10 = 0;
8293 24 break;
8294 }
8295 case itype_faroreswind:
8296 {
8297 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8298 24 tempitem.misc2 = 0;
8299 24 tempitem.misc3 = 0;
8300 24 tempitem.misc4 = 0;
8301 24 tempitem.misc5 = 0;
8302 24 tempitem.misc6 = 0;
8303 24 tempitem.misc7 = 0;
8304 24 tempitem.misc8 = 0;
8305 24 tempitem.misc9 = 0;
8306 24 tempitem.misc10 = 0;
8307 24 tempitem.wpn = 0;
8308 24 tempitem.wpn2 = 0;
8309 24 tempitem.wpn3 = 0;
8310 24 tempitem.wpn4 = 0;
8311 24 tempitem.wpn5 = 0;
8312 24 tempitem.wpn6 = 0;
8313 24 tempitem.wpn7 = 0;
8314 24 tempitem.wpn8 = 0;
8315 24 tempitem.wpn9 = 0;
8316 24 tempitem.wpn10 = 0;
8317 24 break;
8318 }
8319 case itype_nayruslove:
8320 {
8321 24 tempitem.flags &= ~ (ITEM_FLAG5);
8322 24 tempitem.misc2 = 0;
8323 24 tempitem.misc3 = 0;
8324 24 tempitem.misc4 = 0;
8325 24 tempitem.misc5 = 0;
8326 24 tempitem.misc6 = 0;
8327 24 tempitem.misc7 = 0;
8328 24 tempitem.misc8 = 0;
8329 24 tempitem.misc9 = 0;
8330 24 tempitem.misc10 = 0;
8331 24 break;
8332 }
8333 case itype_bomb:
8334 {
8335 27 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8336 27 tempitem.misc4 = 0;
8337 27 tempitem.misc5 = 0;
8338 27 tempitem.misc6 = 0;
8339 27 tempitem.misc7 = 0;
8340 27 tempitem.misc8 = 0;
8341 27 tempitem.misc9 = 0;
8342 27 tempitem.misc10 = 0;
8343 27 tempitem.wpn3 = 0;
8344 27 tempitem.wpn4 = 0;
8345 27 tempitem.wpn5 = 0;
8346 27 tempitem.wpn6 = 0;
8347 27 tempitem.wpn7 = 0;
8348 27 tempitem.wpn8 = 0;
8349 27 tempitem.wpn9 = 0;
8350 27 tempitem.wpn10 = 0;
8351 27 break;
8352 }
8353 case itype_sbomb:
8354 {
8355 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8356 24 tempitem.misc4 = 0;
8357 24 tempitem.misc5 = 0;
8358 24 tempitem.misc6 = 0;
8359 24 tempitem.misc7 = 0;
8360 24 tempitem.misc8 = 0;
8361 24 tempitem.misc9 = 0;
8362 24 tempitem.misc10 = 0;
8363 24 tempitem.wpn3 = 0;
8364 24 tempitem.wpn4 = 0;
8365 24 tempitem.wpn5 = 0;
8366 24 tempitem.wpn6 = 0;
8367 24 tempitem.wpn7 = 0;
8368 24 tempitem.wpn8 = 0;
8369 24 tempitem.wpn9 = 0;
8370 24 tempitem.wpn10 = 0;
8371 24 break;
8372 }
8373 case itype_clock:
8374 {
8375 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8376 24 tempitem.misc2 = 0;
8377 24 tempitem.misc3 = 0;
8378 24 tempitem.misc4 = 0;
8379 24 tempitem.misc5 = 0;
8380 24 tempitem.misc6 = 0;
8381 24 tempitem.misc7 = 0;
8382 24 tempitem.misc8 = 0;
8383 24 tempitem.misc9 = 0;
8384 24 tempitem.misc10 = 0;
8385 24 tempitem.wpn = 0;
8386 24 tempitem.wpn2 = 0;
8387 24 tempitem.wpn3 = 0;
8388 24 tempitem.wpn4 = 0;
8389 24 tempitem.wpn5 = 0;
8390 24 tempitem.wpn6 = 0;
8391 24 tempitem.wpn7 = 0;
8392 24 tempitem.wpn8 = 0;
8393 24 tempitem.wpn9 = 0;
8394 24 tempitem.wpn10 = 0;
8395 24 break;
8396 }
8397 case itype_key:
8398 {
8399 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8400 24 tempitem.misc1 = 0;
8401 24 tempitem.misc2 = 0;
8402 24 tempitem.misc3 = 0;
8403 24 tempitem.misc4 = 0;
8404 24 tempitem.misc5 = 0;
8405 24 tempitem.misc6 = 0;
8406 24 tempitem.misc7 = 0;
8407 24 tempitem.misc8 = 0;
8408 24 tempitem.misc9 = 0;
8409 24 tempitem.misc10 = 0;
8410 24 tempitem.wpn = 0;
8411 24 tempitem.wpn2 = 0;
8412 24 tempitem.wpn3 = 0;
8413 24 tempitem.wpn4 = 0;
8414 24 tempitem.wpn5 = 0;
8415 24 tempitem.wpn6 = 0;
8416 24 tempitem.wpn7 = 0;
8417 24 tempitem.wpn8 = 0;
8418 24 tempitem.wpn9 = 0;
8419 24 tempitem.wpn10 = 0;
8420 24 break;
8421 }
8422 case itype_magiccontainer:
8423 {
8424 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8425 24 tempitem.misc1 = 0;
8426 24 tempitem.misc2 = 0;
8427 24 tempitem.misc3 = 0;
8428 24 tempitem.misc4 = 0;
8429 24 tempitem.misc5 = 0;
8430 24 tempitem.misc6 = 0;
8431 24 tempitem.misc7 = 0;
8432 24 tempitem.misc8 = 0;
8433 24 tempitem.misc9 = 0;
8434 24 tempitem.misc10 = 0;
8435 24 tempitem.wpn = 0;
8436 24 tempitem.wpn2 = 0;
8437 24 tempitem.wpn3 = 0;
8438 24 tempitem.wpn4 = 0;
8439 24 tempitem.wpn5 = 0;
8440 24 tempitem.wpn6 = 0;
8441 24 tempitem.wpn7 = 0;
8442 24 tempitem.wpn8 = 0;
8443 24 tempitem.wpn9 = 0;
8444 24 tempitem.wpn10 = 0;
8445 24 break;
8446 }
8447 case itype_triforcepiece:
8448 {
8449 48 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8450 48 tempitem.misc3 = 0;
8451 48 tempitem.misc4 = 0;
8452 48 tempitem.misc5 = 0;
8453 48 tempitem.misc6 = 0;
8454 48 tempitem.misc7 = 0;
8455 48 tempitem.misc8 = 0;
8456 48 tempitem.misc9 = 0;
8457 48 tempitem.misc10 = 0;
8458 48 tempitem.wpn = 0;
8459 48 tempitem.wpn2 = 0;
8460 48 tempitem.wpn3 = 0;
8461 48 tempitem.wpn4 = 0;
8462 48 tempitem.wpn5 = 0;
8463 48 tempitem.wpn6 = 0;
8464 48 tempitem.wpn7 = 0;
8465 48 tempitem.wpn8 = 0;
8466 48 tempitem.wpn9 = 0;
8467 48 tempitem.wpn10 = 0;
8468 48 break;
8469 }
8470 case itype_map: case itype_compass: case itype_bosskey:
8471 {
8472 72 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8473 72 tempitem.misc1 = 0;
8474 72 tempitem.misc2 = 0;
8475 72 tempitem.misc3 = 0;
8476 72 tempitem.misc4 = 0;
8477 72 tempitem.misc5 = 0;
8478 72 tempitem.misc6 = 0;
8479 72 tempitem.misc7 = 0;
8480 72 tempitem.misc8 = 0;
8481 72 tempitem.misc9 = 0;
8482 72 tempitem.misc10 = 0;
8483 72 tempitem.wpn = 0;
8484 72 tempitem.wpn2 = 0;
8485 72 tempitem.wpn3 = 0;
8486 72 tempitem.wpn4 = 0;
8487 72 tempitem.wpn5 = 0;
8488 72 tempitem.wpn6 = 0;
8489 72 tempitem.wpn7 = 0;
8490 72 tempitem.wpn8 = 0;
8491 72 tempitem.wpn9 = 0;
8492 72 tempitem.wpn10 = 0;
8493 72 break;
8494 }
8495 case itype_quiver:
8496 {
8497 96 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8498 96 tempitem.misc3 = 0;
8499 96 tempitem.misc4 = 0;
8500 96 tempitem.misc5 = 0;
8501 96 tempitem.misc6 = 0;
8502 96 tempitem.misc7 = 0;
8503 96 tempitem.misc8 = 0;
8504 96 tempitem.misc9 = 0;
8505 96 tempitem.misc10 = 0;
8506 96 tempitem.wpn = 0;
8507 96 tempitem.wpn2 = 0;
8508 96 tempitem.wpn3 = 0;
8509 96 tempitem.wpn4 = 0;
8510 96 tempitem.wpn5 = 0;
8511 96 tempitem.wpn6 = 0;
8512 96 tempitem.wpn7 = 0;
8513 96 tempitem.wpn8 = 0;
8514 96 tempitem.wpn9 = 0;
8515 96 tempitem.wpn10 = 0;
8516 96 break;
8517 }
8518 case itype_lkey:
8519 {
8520 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8521 24 tempitem.misc1 = 0;
8522 24 tempitem.misc2 = 0;
8523 24 tempitem.misc3 = 0;
8524 24 tempitem.misc4 = 0;
8525 24 tempitem.misc5 = 0;
8526 24 tempitem.misc6 = 0;
8527 24 tempitem.misc7 = 0;
8528 24 tempitem.misc8 = 0;
8529 24 tempitem.misc9 = 0;
8530 24 tempitem.misc10 = 0;
8531 24 tempitem.wpn = 0;
8532 24 tempitem.wpn2 = 0;
8533 24 tempitem.wpn3 = 0;
8534 24 tempitem.wpn4 = 0;
8535 24 tempitem.wpn5 = 0;
8536 24 tempitem.wpn6 = 0;
8537 24 tempitem.wpn7 = 0;
8538 24 tempitem.wpn8 = 0;
8539 24 tempitem.wpn9 = 0;
8540 24 tempitem.wpn10 = 0;
8541 24 break;
8542 }
8543 case itype_cbyrna:
8544 {
8545 24 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8546 24 tempitem.misc4 = 0;
8547 24 tempitem.misc5 = 0;
8548 24 tempitem.misc6 = 0;
8549 24 tempitem.misc7 = 0;
8550 24 tempitem.misc8 = 0;
8551 24 tempitem.misc9 = 0;
8552 24 tempitem.misc10 = 0;
8553 24 tempitem.wpn6 = 0;
8554 24 tempitem.wpn7 = 0;
8555 24 tempitem.wpn8 = 0;
8556 24 tempitem.wpn9 = 0;
8557 24 tempitem.wpn10 = 0;
8558 24 break;
8559 }
8560 case itype_rupee: case itype_arrowammo:
8561 {
8562 298 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8563 298 tempitem.misc1 = 0;
8564 298 tempitem.misc2 = 0;
8565 298 tempitem.misc3 = 0;
8566 298 tempitem.misc4 = 0;
8567 298 tempitem.misc5 = 0;
8568 298 tempitem.misc6 = 0;
8569 298 tempitem.misc7 = 0;
8570 298 tempitem.misc8 = 0;
8571 298 tempitem.misc9 = 0;
8572 298 tempitem.misc10 = 0;
8573 298 tempitem.wpn = 0;
8574 298 tempitem.wpn2 = 0;
8575 298 tempitem.wpn3 = 0;
8576 298 tempitem.wpn4 = 0;
8577 298 tempitem.wpn5 = 0;
8578 298 tempitem.wpn6 = 0;
8579 298 tempitem.wpn7 = 0;
8580 298 tempitem.wpn8 = 0;
8581 298 tempitem.wpn9 = 0;
8582 298 tempitem.wpn10 = 0;
8583 298 break;
8584 }
8585 case itype_fairy:
8586 {
8587 46 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8588 46 tempitem.misc4 = 0;
8589 46 tempitem.misc5 = 0;
8590 46 tempitem.misc6 = 0;
8591 46 tempitem.misc7 = 0;
8592 46 tempitem.misc8 = 0;
8593 46 tempitem.misc9 = 0;
8594 46 tempitem.misc10 = 0;
8595 46 tempitem.wpn = 0;
8596 46 tempitem.wpn2 = 0;
8597 46 tempitem.wpn3 = 0;
8598 46 tempitem.wpn4 = 0;
8599 46 tempitem.wpn5 = 0;
8600 46 tempitem.wpn6 = 0;
8601 46 tempitem.wpn7 = 0;
8602 46 tempitem.wpn8 = 0;
8603 46 tempitem.wpn9 = 0;
8604 46 tempitem.wpn10 = 0;
8605 46 break;
8606 }
8607 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8608 {
8609 252 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8610 252 tempitem.misc1 = 0;
8611 252 tempitem.misc2 = 0;
8612 252 tempitem.misc3 = 0;
8613 252 tempitem.misc4 = 0;
8614 252 tempitem.misc5 = 0;
8615 252 tempitem.misc6 = 0;
8616 252 tempitem.misc7 = 0;
8617 252 tempitem.misc8 = 0;
8618 252 tempitem.misc9 = 0;
8619 252 tempitem.misc10 = 0;
8620 252 tempitem.wpn = 0;
8621 252 tempitem.wpn2 = 0;
8622 252 tempitem.wpn3 = 0;
8623 252 tempitem.wpn4 = 0;
8624 252 tempitem.wpn5 = 0;
8625 252 tempitem.wpn6 = 0;
8626 252 tempitem.wpn7 = 0;
8627 252 tempitem.wpn8 = 0;
8628 252 tempitem.wpn9 = 0;
8629 252 tempitem.wpn10 = 0;
8630 252 break;
8631 }
8632 case itype_bombbag:
8633 {
8634 96 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8635 96 tempitem.misc3 = 0;
8636 96 tempitem.misc4 = 0;
8637 96 tempitem.misc5 = 0;
8638 96 tempitem.misc6 = 0;
8639 96 tempitem.misc7 = 0;
8640 96 tempitem.misc8 = 0;
8641 96 tempitem.misc9 = 0;
8642 96 tempitem.misc10 = 0;
8643 96 tempitem.wpn = 0;
8644 96 tempitem.wpn2 = 0;
8645 96 tempitem.wpn3 = 0;
8646 96 tempitem.wpn4 = 0;
8647 96 tempitem.wpn5 = 0;
8648 96 tempitem.wpn6 = 0;
8649 96 tempitem.wpn7 = 0;
8650 96 tempitem.wpn8 = 0;
8651 96 tempitem.wpn9 = 0;
8652 96 tempitem.wpn10 = 0;
8653 96 break;
8654 }
8655 case itype_rocs:
8656 {
8657 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8658 24 tempitem.misc1 = 0;
8659 24 tempitem.misc2 = 0;
8660 24 tempitem.misc3 = 0;
8661 24 tempitem.misc4 = 0;
8662 24 tempitem.misc5 = 0;
8663 24 tempitem.misc6 = 0;
8664 24 tempitem.misc7 = 0;
8665 24 tempitem.misc8 = 0;
8666 24 tempitem.misc9 = 0;
8667 24 tempitem.misc10 = 0;
8668 24 tempitem.wpn = 0;
8669 24 tempitem.wpn2 = 0;
8670 24 tempitem.wpn3 = 0;
8671 24 tempitem.wpn4 = 0;
8672 24 tempitem.wpn5 = 0;
8673 24 tempitem.wpn6 = 0;
8674 24 tempitem.wpn7 = 0;
8675 24 tempitem.wpn8 = 0;
8676 24 tempitem.wpn9 = 0;
8677 24 tempitem.wpn10 = 0;
8678 24 break;
8679 }
8680 case itype_hoverboots:
8681 {
8682 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8683 24 tempitem.misc2 = 0;
8684 24 tempitem.misc3 = 0;
8685 24 tempitem.misc4 = 0;
8686 24 tempitem.misc5 = 0;
8687 24 tempitem.misc6 = 0;
8688 24 tempitem.misc7 = 0;
8689 24 tempitem.misc8 = 0;
8690 24 tempitem.misc9 = 0;
8691 24 tempitem.misc10 = 0;
8692 24 tempitem.wpn2 = 0;
8693 24 tempitem.wpn3 = 0;
8694 24 tempitem.wpn4 = 0;
8695 24 tempitem.wpn5 = 0;
8696 24 tempitem.wpn6 = 0;
8697 24 tempitem.wpn7 = 0;
8698 24 tempitem.wpn8 = 0;
8699 24 tempitem.wpn9 = 0;
8700 24 tempitem.wpn10 = 0;
8701 24 break;
8702 }
8703 case itype_spinscroll:
8704 {
8705 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8706 24 tempitem.misc2 = 0;
8707 24 tempitem.misc3 = 0;
8708 24 tempitem.misc4 = 0;
8709 24 tempitem.misc5 = 0;
8710 24 tempitem.misc6 = 0;
8711 24 tempitem.misc7 = 0;
8712 24 tempitem.misc8 = 0;
8713 24 tempitem.misc9 = 0;
8714 24 tempitem.misc10 = 0;
8715 24 tempitem.wpn = 0;
8716 24 tempitem.wpn2 = 0;
8717 24 tempitem.wpn3 = 0;
8718 24 tempitem.wpn4 = 0;
8719 24 tempitem.wpn5 = 0;
8720 24 tempitem.wpn6 = 0;
8721 24 tempitem.wpn7 = 0;
8722 24 tempitem.wpn8 = 0;
8723 24 tempitem.wpn9 = 0;
8724 24 tempitem.wpn10 = 0;
8725 24 break;
8726 }
8727 case itype_crossscroll:
8728 {
8729 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8730 24 tempitem.misc1 = 0;
8731 24 tempitem.misc2 = 0;
8732 24 tempitem.misc3 = 0;
8733 24 tempitem.misc4 = 0;
8734 24 tempitem.misc5 = 0;
8735 24 tempitem.misc6 = 0;
8736 24 tempitem.misc7 = 0;
8737 24 tempitem.misc8 = 0;
8738 24 tempitem.misc9 = 0;
8739 24 tempitem.misc10 = 0;
8740 24 tempitem.wpn = 0;
8741 24 tempitem.wpn2 = 0;
8742 24 tempitem.wpn3 = 0;
8743 24 tempitem.wpn4 = 0;
8744 24 tempitem.wpn5 = 0;
8745 24 tempitem.wpn6 = 0;
8746 24 tempitem.wpn7 = 0;
8747 24 tempitem.wpn8 = 0;
8748 24 tempitem.wpn9 = 0;
8749 24 tempitem.wpn10 = 0;
8750 24 break;
8751 }
8752 case itype_quakescroll:
8753 {
8754 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8755 24 tempitem.misc3 = 0;
8756 24 tempitem.misc4 = 0;
8757 24 tempitem.misc5 = 0;
8758 24 tempitem.misc6 = 0;
8759 24 tempitem.misc7 = 0;
8760 24 tempitem.misc8 = 0;
8761 24 tempitem.misc9 = 0;
8762 24 tempitem.misc10 = 0;
8763 24 tempitem.wpn = 0;
8764 24 tempitem.wpn2 = 0;
8765 24 tempitem.wpn3 = 0;
8766 24 tempitem.wpn4 = 0;
8767 24 tempitem.wpn5 = 0;
8768 24 tempitem.wpn6 = 0;
8769 24 tempitem.wpn7 = 0;
8770 24 tempitem.wpn8 = 0;
8771 24 tempitem.wpn9 = 0;
8772 24 tempitem.wpn10 = 0;
8773 24 break;
8774 }
8775 case itype_whispring:
8776 {
8777 48 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8778 48 tempitem.misc2 = 0;
8779 48 tempitem.misc3 = 0;
8780 48 tempitem.misc4 = 0;
8781 48 tempitem.misc5 = 0;
8782 48 tempitem.misc6 = 0;
8783 48 tempitem.misc7 = 0;
8784 48 tempitem.misc8 = 0;
8785 48 tempitem.misc9 = 0;
8786 48 tempitem.misc10 = 0;
8787 48 tempitem.wpn = 0;
8788 48 tempitem.wpn2 = 0;
8789 48 tempitem.wpn3 = 0;
8790 48 tempitem.wpn4 = 0;
8791 48 tempitem.wpn5 = 0;
8792 48 tempitem.wpn6 = 0;
8793 48 tempitem.wpn7 = 0;
8794 48 tempitem.wpn8 = 0;
8795 48 tempitem.wpn9 = 0;
8796 48 tempitem.wpn10 = 0;
8797 48 break;
8798 }
8799 case itype_chargering:
8800 {
8801 48 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8802 48 tempitem.misc3 = 0;
8803 48 tempitem.misc4 = 0;
8804 48 tempitem.misc5 = 0;
8805 48 tempitem.misc6 = 0;
8806 48 tempitem.misc7 = 0;
8807 48 tempitem.misc8 = 0;
8808 48 tempitem.misc9 = 0;
8809 48 tempitem.misc10 = 0;
8810 48 tempitem.wpn = 0;
8811 48 tempitem.wpn2 = 0;
8812 48 tempitem.wpn3 = 0;
8813 48 tempitem.wpn4 = 0;
8814 48 tempitem.wpn5 = 0;
8815 48 tempitem.wpn6 = 0;
8816 48 tempitem.wpn7 = 0;
8817 48 tempitem.wpn8 = 0;
8818 48 tempitem.wpn9 = 0;
8819 48 tempitem.wpn10 = 0;
8820 48 break;
8821 }
8822 case itype_perilscroll:
8823 {
8824 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8825 24 tempitem.misc2 = 0;
8826 24 tempitem.misc3 = 0;
8827 24 tempitem.misc4 = 0;
8828 24 tempitem.misc5 = 0;
8829 24 tempitem.misc6 = 0;
8830 24 tempitem.misc7 = 0;
8831 24 tempitem.misc8 = 0;
8832 24 tempitem.misc9 = 0;
8833 24 tempitem.misc10 = 0;
8834 24 tempitem.wpn = 0;
8835 24 tempitem.wpn2 = 0;
8836 24 tempitem.wpn3 = 0;
8837 24 tempitem.wpn4 = 0;
8838 24 tempitem.wpn5 = 0;
8839 24 tempitem.wpn6 = 0;
8840 24 tempitem.wpn7 = 0;
8841 24 tempitem.wpn8 = 0;
8842 24 tempitem.wpn9 = 0;
8843 24 tempitem.wpn10 = 0;
8844 24 break;
8845 }
8846 case itype_wealthmedal:
8847 {
8848 72 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8849 72 tempitem.misc2 = 0;
8850 72 tempitem.misc3 = 0;
8851 72 tempitem.misc4 = 0;
8852 72 tempitem.misc5 = 0;
8853 72 tempitem.misc6 = 0;
8854 72 tempitem.misc7 = 0;
8855 72 tempitem.misc8 = 0;
8856 72 tempitem.misc9 = 0;
8857 72 tempitem.misc10 = 0;
8858 72 tempitem.wpn = 0;
8859 72 tempitem.wpn2 = 0;
8860 72 tempitem.wpn3 = 0;
8861 72 tempitem.wpn4 = 0;
8862 72 tempitem.wpn5 = 0;
8863 72 tempitem.wpn6 = 0;
8864 72 tempitem.wpn7 = 0;
8865 72 tempitem.wpn8 = 0;
8866 72 tempitem.wpn9 = 0;
8867 72 tempitem.wpn10 = 0;
8868 72 break;
8869 }
8870 case itype_heartring:
8871 {
8872 72 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8873 72 tempitem.misc3 = 0;
8874 72 tempitem.misc4 = 0;
8875 72 tempitem.misc5 = 0;
8876 72 tempitem.misc6 = 0;
8877 72 tempitem.misc7 = 0;
8878 72 tempitem.misc8 = 0;
8879 72 tempitem.misc9 = 0;
8880 72 tempitem.misc10 = 0;
8881 72 tempitem.wpn = 0;
8882 72 tempitem.wpn2 = 0;
8883 72 tempitem.wpn3 = 0;
8884 72 tempitem.wpn4 = 0;
8885 72 tempitem.wpn5 = 0;
8886 72 tempitem.wpn6 = 0;
8887 72 tempitem.wpn7 = 0;
8888 72 tempitem.wpn8 = 0;
8889 72 tempitem.wpn9 = 0;
8890 72 tempitem.wpn10 = 0;
8891 72 break;
8892 }
8893 case itype_magicring:
8894 {
8895 96 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8896 96 tempitem.misc3 = 0;
8897 96 tempitem.misc4 = 0;
8898 96 tempitem.misc5 = 0;
8899 96 tempitem.misc6 = 0;
8900 96 tempitem.misc7 = 0;
8901 96 tempitem.misc8 = 0;
8902 96 tempitem.misc9 = 0;
8903 96 tempitem.misc10 = 0;
8904 96 tempitem.wpn = 0;
8905 96 tempitem.wpn2 = 0;
8906 96 tempitem.wpn3 = 0;
8907 96 tempitem.wpn4 = 0;
8908 96 tempitem.wpn5 = 0;
8909 96 tempitem.wpn6 = 0;
8910 96 tempitem.wpn7 = 0;
8911 96 tempitem.wpn8 = 0;
8912 96 tempitem.wpn9 = 0;
8913 96 tempitem.wpn10 = 0;
8914 96 break;
8915 }
8916 case itype_spinscroll2:
8917 {
8918 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8919 24 tempitem.misc2 = 0;
8920 24 tempitem.misc3 = 0;
8921 24 tempitem.misc4 = 0;
8922 24 tempitem.misc5 = 0;
8923 24 tempitem.misc6 = 0;
8924 24 tempitem.misc7 = 0;
8925 24 tempitem.misc8 = 0;
8926 24 tempitem.misc9 = 0;
8927 24 tempitem.misc10 = 0;
8928 24 tempitem.wpn = 0;
8929 24 tempitem.wpn2 = 0;
8930 24 tempitem.wpn3 = 0;
8931 24 tempitem.wpn4 = 0;
8932 24 tempitem.wpn5 = 0;
8933 24 tempitem.wpn6 = 0;
8934 24 tempitem.wpn7 = 0;
8935 24 tempitem.wpn8 = 0;
8936 24 tempitem.wpn9 = 0;
8937 24 tempitem.wpn10 = 0;
8938 24 break;
8939 }
8940 case itype_quakescroll2:
8941 {
8942 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8943 24 tempitem.misc3 = 0;
8944 24 tempitem.misc4 = 0;
8945 24 tempitem.misc5 = 0;
8946 24 tempitem.misc6 = 0;
8947 24 tempitem.misc7 = 0;
8948 24 tempitem.misc8 = 0;
8949 24 tempitem.misc9 = 0;
8950 24 tempitem.misc10 = 0;
8951 24 tempitem.wpn = 0;
8952 24 tempitem.wpn2 = 0;
8953 24 tempitem.wpn3 = 0;
8954 24 tempitem.wpn4 = 0;
8955 24 tempitem.wpn5 = 0;
8956 24 tempitem.wpn6 = 0;
8957 24 tempitem.wpn7 = 0;
8958 24 tempitem.wpn8 = 0;
8959 24 tempitem.wpn9 = 0;
8960 24 tempitem.wpn10 = 0;
8961 24 break;
8962 }
8963 case itype_agony:
8964 {
8965 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8966 24 tempitem.misc2 = 0;
8967 24 tempitem.misc3 = 0;
8968 24 tempitem.misc4 = 0;
8969 24 tempitem.misc5 = 0;
8970 24 tempitem.misc6 = 0;
8971 24 tempitem.misc7 = 0;
8972 24 tempitem.misc8 = 0;
8973 24 tempitem.misc9 = 0;
8974 24 tempitem.misc10 = 0;
8975 24 tempitem.wpn = 0;
8976 24 tempitem.wpn2 = 0;
8977 24 tempitem.wpn3 = 0;
8978 24 tempitem.wpn4 = 0;
8979 24 tempitem.wpn5 = 0;
8980 24 tempitem.wpn6 = 0;
8981 24 tempitem.wpn7 = 0;
8982 24 tempitem.wpn8 = 0;
8983 24 tempitem.wpn9 = 0;
8984 24 tempitem.wpn10 = 0;
8985 24 break;
8986 }
8987 case itype_stompboots:
8988 {
8989 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8990 24 tempitem.misc1 = 0;
8991 24 tempitem.misc2 = 0;
8992 24 tempitem.misc3 = 0;
8993 24 tempitem.misc4 = 0;
8994 24 tempitem.misc5 = 0;
8995 24 tempitem.misc6 = 0;
8996 24 tempitem.misc7 = 0;
8997 24 tempitem.misc8 = 0;
8998 24 tempitem.misc9 = 0;
8999 24 tempitem.misc10 = 0;
9000 24 tempitem.wpn = 0;
9001 24 tempitem.wpn2 = 0;
9002 24 tempitem.wpn3 = 0;
9003 24 tempitem.wpn4 = 0;
9004 24 tempitem.wpn5 = 0;
9005 24 tempitem.wpn6 = 0;
9006 24 tempitem.wpn7 = 0;
9007 24 tempitem.wpn8 = 0;
9008 24 tempitem.wpn9 = 0;
9009 24 tempitem.wpn10 = 0;
9010 24 break;
9011 }
9012 case itype_whimsicalring:
9013 {
9014 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9015 24 tempitem.misc2 = 0;
9016 24 tempitem.misc3 = 0;
9017 24 tempitem.misc4 = 0;
9018 24 tempitem.misc5 = 0;
9019 24 tempitem.misc6 = 0;
9020 24 tempitem.misc7 = 0;
9021 24 tempitem.misc8 = 0;
9022 24 tempitem.misc9 = 0;
9023 24 tempitem.misc10 = 0;
9024 24 tempitem.wpn = 0;
9025 24 tempitem.wpn2 = 0;
9026 24 tempitem.wpn3 = 0;
9027 24 tempitem.wpn4 = 0;
9028 24 tempitem.wpn5 = 0;
9029 24 tempitem.wpn6 = 0;
9030 24 tempitem.wpn7 = 0;
9031 24 tempitem.wpn8 = 0;
9032 24 tempitem.wpn9 = 0;
9033 24 tempitem.wpn10 = 0;
9034 24 break;
9035 }
9036 case itype_perilring:
9037 {
9038 24 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9039 24 tempitem.misc2 = 0;
9040 24 tempitem.misc3 = 0;
9041 24 tempitem.misc4 = 0;
9042 24 tempitem.misc5 = 0;
9043 24 tempitem.misc6 = 0;
9044 24 tempitem.misc7 = 0;
9045 24 tempitem.misc8 = 0;
9046 24 tempitem.misc9 = 0;
9047 24 tempitem.misc10 = 0;
9048 24 tempitem.wpn = 0;
9049 24 tempitem.wpn2 = 0;
9050 24 tempitem.wpn3 = 0;
9051 24 tempitem.wpn4 = 0;
9052 24 tempitem.wpn5 = 0;
9053 24 tempitem.wpn6 = 0;
9054 24 tempitem.wpn7 = 0;
9055 24 tempitem.wpn8 = 0;
9056 24 tempitem.wpn9 = 0;
9057 24 tempitem.wpn10 = 0;
9058 24 break;
9059 }
9060 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9061 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9062 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9063 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9064 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9065 {
9066 1184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9067 1184 tempitem.misc1 = 0;
9068 1184 tempitem.misc2 = 0;
9069 1184 tempitem.misc3 = 0;
9070 1184 tempitem.misc4 = 0;
9071 1184 tempitem.misc5 = 0;
9072 1184 tempitem.misc6 = 0;
9073 1184 tempitem.misc7 = 0;
9074 1184 tempitem.misc8 = 0;
9075 1184 tempitem.misc9 = 0;
9076 1184 tempitem.misc10 = 0;
9077 1184 tempitem.wpn = 0;
9078 1184 tempitem.wpn2 = 0;
9079 1184 tempitem.wpn3 = 0;
9080 1184 tempitem.wpn4 = 0;
9081 1184 tempitem.wpn5 = 0;
9082 1184 tempitem.wpn6 = 0;
9083 1184 tempitem.wpn7 = 0;
9084 1184 tempitem.wpn8 = 0;
9085 1184 tempitem.wpn9 = 0;
9086 1184 tempitem.wpn10 = 0;
9087 1184 break;
9088 }
9089 }
9090 6144 }
9091 //Port quest rules to items
9092
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version <= 31)
9093 {
9094
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 6117 times.
6144 if(tempitem.family == itype_bomb)
9095 {
9096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9097 27 else tempitem.flags &= ~ ITEM_FLAG2;
9098 27 }
9099
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6093 times.
6117 else if(tempitem.family == itype_sbomb)
9100 {
9101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9102 24 else tempitem.flags &= ~ ITEM_FLAG2;
9103 24 }
9104
9105
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 6021 times.
6093 else if(tempitem.family == itype_brang)
9106 {
9107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9108 72 else tempitem.flags &= ~ ITEM_FLAG4;
9109 72 }
9110
2/2
✓ Branch 0 taken 5994 times.
✓ Branch 1 taken 27 times.
6021 else if(tempitem.family == itype_wand)
9111 {
9112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9113 27 else tempitem.flags &= ~ ITEM_FLAG3;
9114 27 }
9115 6144 }
9116
9117 //Port quest rules to items
9118
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version <= 37)
9119 {
9120
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6120 times.
6144 if(tempitem.family == itype_flippers)
9121 {
9122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9123 24 else tempitem.flags &= ~ ITEM_FLAG1;
9124 24 }
9125
2/2
✓ Branch 0 taken 4743 times.
✓ Branch 1 taken 1377 times.
6120 else if(tempitem.family == itype_sword)
9126 {
9127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377 times.
1377 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9128 1377 else tempitem.flags &= ~ ITEM_FLAG5;
9129 1377 }
9130
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 4716 times.
4743 else if(tempitem.family == itype_wand)
9131 {
9132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9133 27 else tempitem.flags &= ~ ITEM_FLAG5;
9134 27 }
9135
4/4
✓ Branch 0 taken 4689 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 4631 times.
4716 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9136 {
9137 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9138
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9139 79 else tempitem.flags &= ~ ITEM_FLAG3;
9140 85 }
9141 6144 }
9142
9143
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 38)
9144 {
9145
4/4
✓ Branch 0 taken 6072 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 6024 times.
6144 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9146 {
9147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9148 120 else tempitem.flags &= ~ITEM_FLAG4;
9149
9150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9151 120 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9152 120 }
9153
2/2
✓ Branch 0 taken 5952 times.
✓ Branch 1 taken 72 times.
6024 else if(tempitem.family == itype_arrow)
9154 {
9155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9156 72 else tempitem.flags &= ~ITEM_FLAG4;
9157
9158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9159 72 else tempitem.flags |= ITEM_FLAG2;
9160 72 }
9161 6144 }
9162
9163
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 39)
9164 {
9165
6/6
✓ Branch 0 taken 6120 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 6093 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 6035 times.
6144 if(tempitem.family == itype_dinsfire || tempitem.family == itype_book || tempitem.family == itype_candle)
9166 {
9167
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9168 109 else tempitem.flags &= ~ITEM_FLAG5;
9169 109 }
9170
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 5987 times.
6035 else if(tempitem.family == itype_potion)
9171 {
9172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9173 {
9174 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9175 }
9176 else
9177 {
9178 48 tempitem.flags |= ITEM_FLAG3;
9179
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 30 times.
48 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9180 30 else tempitem.flags &= ~ITEM_FLAG4;
9181 }
9182 48 }
9183
2/2
✓ Branch 0 taken 5939 times.
✓ Branch 1 taken 48 times.
5987 else if(tempitem.family == itype_triforcepiece)
9184 {
9185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9186 {
9187 tempitem.flags |= ITEM_FLAG3;
9188 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9189 else tempitem.flags &= ~ITEM_FLAG4;
9190 }
9191 else
9192 {
9193 48 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9194 }
9195 48 }
9196 6144 }
9197
9198
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 40)
9199 {
9200
4/4
✓ Branch 0 taken 6072 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 6048 times.
6144 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9201 {
9202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9203 96 else tempitem.flags &= ~ITEM_FLAG1;
9204 96 }
9205
8/8
✓ Branch 0 taken 5990 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 4613 times.
✓ Branch 3 taken 1377 times.
✓ Branch 4 taken 4586 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 4562 times.
6048 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9206 {
9207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1486 times.
1486 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9208 1486 else tempitem.flags &= ~ITEM_FLAG8;
9209 1486 }
9210
6/6
✓ Branch 0 taken 4767 times.
✓ Branch 1 taken 1377 times.
✓ Branch 2 taken 4740 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 4716 times.
6144 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9211 {
9212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1428 times.
1428 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9213 1428 else tempitem.flags &= ~ITEM_FLAG7;
9214 1428 }
9215
2/2
✓ Branch 0 taken 4692 times.
✓ Branch 1 taken 24 times.
4716 else if(tempitem.family == itype_cbyrna)
9216 {
9217 24 tempitem.flags |= ITEM_FLAG7;
9218 24 }
9219 6144 }
9220
9221
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 41 )
9222 {
9223
2/2
✓ Branch 0 taken 4767 times.
✓ Branch 1 taken 1377 times.
6144 if(tempitem.family == itype_sword)
9224 {
9225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377 times.
1377 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9226 1377 else tempitem.flags &= ~ITEM_FLAG9;
9227
9228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377 times.
1377 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9229 1377 else tempitem.flags &= ~ITEM_FLAG10;
9230 1377 }
9231 6144 }
9232
9233
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 42 )
9234 {
9235
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 6117 times.
6144 if(tempitem.family == itype_wand)
9236 {
9237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9238 27 else tempitem.flags &= ~ITEM_FLAG3;
9239
9240 27 tempitem.flags &= ~ITEM_FLAG6;
9241 27 }
9242
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6093 times.
6117 else if(tempitem.family == itype_hammer)
9243 {
9244 24 tempitem.flags &= ~ITEM_FLAG3;
9245 24 }
9246
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6069 times.
6093 else if(tempitem.family == itype_cbyrna)
9247 {
9248 24 tempitem.flags |= ITEM_FLAG3;
9249
9250 24 tempitem.flags &= ~ITEM_FLAG6;
9251 24 }
9252
2/2
✓ Branch 0 taken 4692 times.
✓ Branch 1 taken 1377 times.
6069 else if(tempitem.family == itype_sword)
9253 {
9254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377 times.
1377 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9255 1377 else tempitem.flags &= ~ITEM_FLAG6;
9256 1377 }
9257 6144 }
9258
9259
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 43 )
9260 {
9261
2/2
✓ Branch 0 taken 6106 times.
✓ Branch 1 taken 38 times.
6144 if(tempitem.family == itype_whistle)
9262 {
9263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9264 38 else tempitem.flags &= ~ITEM_FLAG3;
9265 38 }
9266 6144 }
9267
9268
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 45 )
9269 {
9270
2/2
✓ Branch 0 taken 6120 times.
✓ Branch 1 taken 24 times.
6144 if(tempitem.family == itype_flippers)
9271 {
9272 24 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9273 24 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9274 24 }
9275 6144 }
9276
9277
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 46 )
9278 {
9279
2/2
✓ Branch 0 taken 6120 times.
✓ Branch 1 taken 24 times.
6144 if(tempitem.family == itype_raft)
9280 {
9281 24 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9282 24 }
9283 6144 }
9284
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if ( s_version < 34 ) //! set the default counter for older quests.
9285 {
9286
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6120 times.
6144 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9287 {
9288 24 tempitem.cost_counter[0] = 1;
9289 24 }
9290 else
9291 {
9292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6120 times.
6120 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9293 tempitem.cost_counter[0] = 4;
9294 else
9295 {
9296 6120 tempitem.cost_amount[0] = 0;
9297 6120 tempitem.cost_counter[0] = -1;
9298 }
9299 }
9300 6144 }
9301
9302
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if ( s_version < 35 ) //new Lens of Truth flags
9303 {
9304
2/2
✓ Branch 0 taken 6120 times.
✓ Branch 1 taken 24 times.
6144 if ( tempitem.family == itype_lens )
9305 {
9306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if ( get_bit(quest_rules,qr_RAFTLENS) )
9307 {
9308 tempitem.flags |= ITEM_FLAG4;
9309 }
9310
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 if ( get_bit(quest_rules,qr_LENSHINTS) )
9311 {
9312 5 tempitem.flags |= ITEM_FLAG1;
9313 5 }
9314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9315 {
9316 tempitem.flags |= ITEM_FLAG5;
9317 }
9318 24 }
9319 6144 }
9320
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9321 {
9322
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 6144 times.
55296 for ( int32_t q = 0; q < 8; q++ )
9323 {
9324 49152 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9325 49152 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9326 49152 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9327 49152 tempitem.sprite_initiald[q] = 0;
9328 49152 }
9329
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 6144 times.
18432 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9330 6144 tempitem.sprite_script = 0;
9331 6144 }
9332
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9333 {
9334 6144 tempitem.pickupflag = 0;
9335 6144 }
9336
9337
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 51 )
9338 {
9339
2/2
✓ Branch 0 taken 6086 times.
✓ Branch 1 taken 58 times.
6144 if( tempitem.family == itype_candle )
9340 {
9341 58 tempitem.misc4 = 50; //Step speed
9342 58 }
9343 6144 }
9344
9345
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if( s_version < 52 )
9346 {
9347
2/2
✓ Branch 0 taken 6072 times.
✓ Branch 1 taken 72 times.
6144 if( tempitem.family == itype_shield )
9348 72 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9349 6144 }
9350
9351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(tempitem.fam_type==0) // Always do this
9352 tempitem.fam_type=1;
9353
9354 6400 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9355 6400 }
9356 25 }
9357
9358 25 return 0;
9359 25 }
9360
9361 static bool did_init_def_items = false;
9362 12800 void init_def_items()
9363 {
9364
2/2
✓ Branch 0 taken 12790 times.
✓ Branch 1 taken 10 times.
12800 if(did_init_def_items) return;
9365 10 did_init_def_items = true;
9366 10 default_items[3].cost_counter[1] = crBOMBS;
9367 10 default_items[13].cost_counter[1] = crARROWS;
9368 10 default_items[14].cost_counter[1] = crARROWS;
9369 10 default_items[48].cost_counter[1] = crBOMBS;
9370 10 default_items[57].cost_counter[1] = crARROWS;
9371 12800 }
9372 12800 void reset_itembuf(itemdata *item, int32_t id)
9373 {
9374 12800 init_def_items();
9375
2/2
✓ Branch 0 taken 5650 times.
✓ Branch 1 taken 7150 times.
12800 if(id<iLast)
9376 {
9377 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9378 7150 word tile = item->tile;
9379 7150 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9380 7150 int32_t ltm = item->ltm;
9381
9382 7150 memcpy(item,&default_items[id],sizeof(itemdata));
9383 7150 item->tile = tile;
9384 7150 item->misc_flags = miscs;
9385 7150 item->csets = cset;
9386 7150 item->frames = frames;
9387 7150 item->speed = speed;
9388 7150 item->delay = delay;
9389 7150 item->ltm = ltm;
9390 7150 }
9391 12800 }
9392
9393 2560 void reset_itemname(int32_t id)
9394 {
9395 2560 sprintf(item_string[id],"zz%03d",id);
9396
9397
2/2
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1430 times.
2560 if(id < iLast)
9398 1430 strcpy(item_string[id],old_item_string[id]);
9399 2560 }
9400
9401 25 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9402 {
9403 25 word weapons_to_read=MAXWPNS;
9404 int32_t dummy;
9405 byte padding;
9406 wpndata tempweapon;
9407 25 word s_version=0, s_cversion=0;
9408
9409
9410
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x186)
9411 {
9412 weapons_to_read=64;
9413 }
9414
9415
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x185)
9416 {
9417 weapons_to_read=32;
9418 }
9419
9420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version > 0x192)
9421 {
9422 25 weapons_to_read=0;
9423
9424 //section version info
9425
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
9426 {
9427 return qe_invalid;
9428 }
9429
9430 25 FFCore.quest_format[vWeaponSprites] = s_version;
9431
9432 //al_trace("Weapons version %d\n", s_version);
9433
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
9434 {
9435 return qe_invalid;
9436 }
9437
9438 //section size
9439
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
9440 {
9441 return qe_invalid;
9442 }
9443
9444 //finally... section data
9445
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&weapons_to_read,f,true))
9446 {
9447 return qe_invalid;
9448 }
9449 25 }
9450
9451
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version>2)
9452 {
9453
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<weapons_to_read; i++)
9454 {
9455 char tempname[64];
9456
9457
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!pfread(tempname, 64, f, keepdata))
9458 {
9459 return qe_invalid;
9460 }
9461
9462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(keepdata)
9463 {
9464 6400 strcpy(weapon_string[i], tempname);
9465 6400 }
9466 6400 }
9467
9468
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<4)
9469 {
9470 if(keepdata)
9471 {
9472 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9473 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9474 }
9475 }
9476
9477
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<5)
9478 {
9479 if(keepdata)
9480 {
9481 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9482 }
9483 }
9484
9485 /*
9486 if (s_version<6)
9487 {
9488 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9489 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9490 }
9491 */
9492 25 }
9493 else
9494 {
9495 if(keepdata)
9496 for(int32_t i=0; i<WPNCNT; i++)
9497 reset_weaponname(i);
9498 }
9499
9500
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<weapons_to_read; i++)
9501 {
9502 6400 word oldtile = 0;
9503
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if (s_version < 8)
9504 {
9505
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if (!p_igetw(&oldtile, f, true))
9506 return qe_invalid;
9507 6144 }
9508
9509
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempweapon.misc,f,true))
9510 {
9511 return qe_invalid;
9512 }
9513
9514
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempweapon.csets,f,true))
9515 {
9516 return qe_invalid;
9517 }
9518
9519
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempweapon.frames,f,true))
9520 {
9521 return qe_invalid;
9522 }
9523
9524
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempweapon.speed,f,true))
9525 {
9526 return qe_invalid;
9527 }
9528
9529
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempweapon.type,f,true))
9530 {
9531 return qe_invalid;
9532 }
9533
9534
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 256 times.
6400 if ( s_version >= 7 )
9535 {
9536
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetw(&tempweapon.script,f,true))
9537 {
9538 return qe_invalid;
9539 }
9540
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_igetl(&tempweapon.tile,f,true))
9541 {
9542 return qe_invalid;
9543 }
9544 256 }
9545
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 6144 times.
6400 if ( s_version < 7 )
9546 {
9547 6144 tempweapon.tile = oldtile;
9548 6144 }
9549
9550
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(Header->zelda_version < 0x193)
9551 {
9552 if(!p_getc(&padding,f,true))
9553 {
9554 return qe_invalid;
9555 }
9556 }
9557
9558
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(s_version < 6)
9559 {
9560 if(i==ewFIRETRAIL)
9561 {
9562 tempweapon.misc |= WF_BEHIND;
9563 }
9564 else
9565 tempweapon.misc &= ~WF_BEHIND;
9566 }
9567
9568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(keepdata==true)
9569 {
9570 6400 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9571 6400 }
9572 6400 }
9573
9574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
9575 {
9576
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<2)
9577 {
9578 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9579 }
9580
9581
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<5)
9582 {
9583 wpnsbuf[iwQuarterHearts].tile=1;
9584 wpnsbuf[iwQuarterHearts].csets=1;
9585 }
9586
9587
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x176)
9588 {
9589 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9590 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9591 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9592 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9593 }
9594
9595
1/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if((Header->zelda_version < 0x192)||
9596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9597 {
9598 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9599 }
9600
9601
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if((Header->zelda_version < 0x210))
9602 {
9603 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9604 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9605 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9606 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9607 }
9608 25 }
9609
9610 25 return 0;
9611 25 }
9612
9613 25 void init_guys(int32_t guyversion)
9614 {
9615
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<MAXGUYS; i++)
9616 {
9617 12800 guysbuf[i] = default_guys[0];
9618 12800 }
9619
9620
2/2
✓ Branch 0 taken 4425 times.
✓ Branch 1 taken 25 times.
4450 for(int32_t i=0; i<OLDMAXGUYS; i++)
9621 {
9622 4425 guysbuf[i] = default_guys[i];
9623
2/2
✓ Branch 0 taken 4375 times.
✓ Branch 1 taken 50 times.
4425 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9624 4425 guysbuf[i].spr_death = iwDeath;
9625 4425 guysbuf[i].spr_spawn = iwSpawn;
9626 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4425 if(guyversion<=3 && i==ePATRABS)
9628 {
9629 guysbuf[i].bosspal=spDIG;
9630 guysbuf[i].cset=14;
9631 guysbuf[i].misc9=14;
9632 }
9633
9634
1/2
✓ Branch 0 taken 4425 times.
✗ Branch 1 not taken.
4425 if(guyversion<=3)
9635 {
9636 // Rope/Ghini Flash rules
9637 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9638 {
9639 if(i==eROPE2)
9640 {
9641 guysbuf[i].flags2 &= ~guy_flashing;
9642 }
9643 }
9644
9645 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9646 {
9647 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9648 {
9649 guysbuf[i].flags2 &= ~guy_flashing;
9650 }
9651 }
9652
9653 if(i==eGHINI2)
9654 {
9655 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9656 {
9657 guysbuf[i].flags2 |= guy_blinking;
9658 }
9659
9660 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9661 {
9662 guysbuf[i].flags2 |= guy_transparent;
9663 }
9664 }
9665 }
9666
9667 // Darknut fix
9668
10/10
✓ Branch 0 taken 4400 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 4375 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 4350 times.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 4325 times.
✓ Branch 7 taken 25 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 4300 times.
4425 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9669 {
9670
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 95 times.
125 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9671 {
9672 30 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9673 30 guysbuf[i].s_width=guysbuf[i].e_width;
9674 30 guysbuf[i].s_height=guysbuf[i].e_height;
9675 30 }
9676 95 else guysbuf[i].s_tile=860;
9677
9678
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9679 {
9680 guysbuf[i].flags |= guy_bkshield;
9681 }
9682 125 }
9683
9684
3/4
✓ Branch 0 taken 4400 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 4425 times.
✗ Branch 3 not taken.
4425 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9685 {
9686 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9687 }
9688 4425 }
9689 25 }
9690
9691 void reset_weaponname(int32_t i)
9692 {
9693 if(i<wLast)
9694 {
9695 strcpy(weapon_string[i],old_weapon_string[i]);
9696 }
9697 else
9698 sprintf(weapon_string[i],"zz%03d",i);
9699 }
9700
9701 25 void init_item_drop_sets()
9702 {
9703
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9704 {
9705 // item_drop_sets[i] = default_item_drop_sets[0];
9706 6400 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9707 6400 }
9708
9709
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 25 times.
350 for(int32_t i=0; i<isMAX; i++)
9710 {
9711 325 item_drop_sets[i] = default_item_drop_sets[i];
9712
9713 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9714
2/2
✓ Branch 0 taken 3250 times.
✓ Branch 1 taken 325 times.
3575 for(int32_t j=0; j<10; ++j)
9715 {
9716 3250 int32_t it = item_drop_sets[i].item[j];
9717
9718
3/4
✓ Branch 0 taken 2300 times.
✓ Branch 1 taken 950 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 150 times.
3250 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9719
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 2150 times.
2300 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9720 {
9721 150 item_drop_sets[i].chance[j+1]=0;
9722 150 }
9723
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 3000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
3100 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9724 {
9725 item_drop_sets[i].chance[j+1]=0;
9726 }
9727
9728 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9729
1/2
✓ Branch 0 taken 3250 times.
✗ Branch 1 not taken.
3250 if(itemsbuf[it].family == itype_misc)
9730 {
9731 // If a non-gameplay item was selected, then item drop was aborted.
9732 // Reflect this by increasing the 'Nothing' chance accordingly.
9733 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9734 item_drop_sets[i].chance[j+1]=0;
9735 }
9736 3250 }
9737 325 }
9738 25 }
9739
9740 25 void init_favorites()
9741 {
9742
2/2
✓ Branch 0 taken 2500 times.
✓ Branch 1 taken 25 times.
2525 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9743 {
9744 2500 favorite_combos[i]=-1;
9745 2500 }
9746
9747
2/2
✓ Branch 0 taken 2500 times.
✓ Branch 1 taken 25 times.
2525 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9748 {
9749 2500 favorite_comboaliases[i]=-1;
9750 2500 }
9751 25 }
9752
9753 const char *ctype_name[cMAX]=
9754 {
9755 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9756 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9757 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9758 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9759 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9760 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9761 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9762 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9763 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9764 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9765 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9766 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9767 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9768 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9769 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9770 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9771 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9772 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9773 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9774 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9775 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9776 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9777 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9778 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9779 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9780 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9781 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9782 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9783
9784 };
9785
9786 49 int32_t init_combo_classes()
9787 {
9788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9789
2/2
✓ Branch 0 taken 8722 times.
✓ Branch 1 taken 49 times.
8771 for(int32_t i=0; i<cMAX; i++)
9790 {
9791 8722 combo_class_buf[i] = default_combo_classes[i];
9792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8722 times.
8722 if ( char const* nm = zi->getComboTypeName(i) )
9793 {
9794 8722 size_t len = strlen(nm);
9795
2/2
✓ Branch 0 taken 558208 times.
✓ Branch 1 taken 8722 times.
566930 for ( size_t q = 0; q < 64; q++ )
9796 {
9797
2/2
✓ Branch 0 taken 129262 times.
✓ Branch 1 taken 428946 times.
558208 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9798 558208 }
9799 8722 }
9800 8722 }
9801
9802 49 return 0;
9803 }
9804
9805 24 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9806 {
9807
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 assert(v_herosprites < 6);
9808 //these are here to bypass compiler warnings about unused arguments
9809 24 cv_herosprites=cv_herosprites;
9810
9811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(keepdata)
9812 {
9813 24 zinit.hero_swim_speed=67; //default
9814 24 setupherotiles(zinit.heroAnimationStyle);
9815 24 setupherodefenses();
9816 24 setupherooffsets();
9817 24 }
9818
9819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>=0)
9820 {
9821 word tile, tile2;
9822 byte flip, extend, dummy_byte;
9823
9824
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
9825 {
9826
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
9827 {
9828 return qe_invalid;
9829 }
9830
9831
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
9832 {
9833 return qe_invalid;
9834 }
9835
9836
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
9837 {
9838 return qe_invalid;
9839 }
9840
9841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
9842 {
9843 96 walkspr[i][spr_tile]=(int32_t)tile;
9844 96 walkspr[i][spr_flip]=(int32_t)flip;
9845 96 walkspr[i][spr_extend]=(int32_t)extend;
9846 96 }
9847 96 }
9848
9849
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
9850 {
9851
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
9852 {
9853 return qe_invalid;
9854 }
9855
9856
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
9857 {
9858 return qe_invalid;
9859 }
9860
9861
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
9862 {
9863 return qe_invalid;
9864 }
9865
9866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
9867 {
9868 96 stabspr[i][spr_tile]=(int32_t)tile;
9869 96 stabspr[i][spr_flip]=(int32_t)flip;
9870 96 stabspr[i][spr_extend]=(int32_t)extend;
9871 96 }
9872 96 }
9873
9874
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
9875 {
9876
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
9877 {
9878 return qe_invalid;
9879 }
9880
9881
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
9882 {
9883 return qe_invalid;
9884 }
9885
9886
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
9887 {
9888 return qe_invalid;
9889 }
9890
9891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
9892 {
9893 96 slashspr[i][spr_tile]=(int32_t)tile;
9894 96 slashspr[i][spr_flip]=(int32_t)flip;
9895 96 slashspr[i][spr_extend]=(int32_t)extend;
9896 96 }
9897 96 }
9898
9899
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
9900 {
9901
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
9902 {
9903 return qe_invalid;
9904 }
9905
9906
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
9907 {
9908 return qe_invalid;
9909 }
9910
9911
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
9912 {
9913 return qe_invalid;
9914 }
9915
9916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
9917 {
9918 96 floatspr[i][spr_tile]=(int32_t)tile;
9919 96 floatspr[i][spr_flip]=(int32_t)flip;
9920 96 floatspr[i][spr_extend]=(int32_t)extend;
9921 96 }
9922 96 }
9923
9924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>1)
9925 {
9926
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
9927 {
9928
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
9929 {
9930 return qe_invalid;
9931 }
9932
9933
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
9934 {
9935 return qe_invalid;
9936 }
9937
9938
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
9939 {
9940 return qe_invalid;
9941 }
9942
9943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
9944 {
9945 96 swimspr[i][spr_tile]=(int32_t)tile;
9946 96 swimspr[i][spr_flip]=(int32_t)flip;
9947 96 swimspr[i][spr_extend]=(int32_t)extend;
9948 96 }
9949 96 }
9950 24 }
9951
9952
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
9953 {
9954
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
9955 {
9956 return qe_invalid;
9957 }
9958
9959
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
9960 {
9961 return qe_invalid;
9962 }
9963
9964
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
9965 {
9966 return qe_invalid;
9967 }
9968
9969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
9970 {
9971 96 divespr[i][spr_tile]=(int32_t)tile;
9972 96 divespr[i][spr_flip]=(int32_t)flip;
9973 96 divespr[i][spr_extend]=(int32_t)extend;
9974 96 }
9975 96 }
9976
9977
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
9978 {
9979
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
9980 {
9981 return qe_invalid;
9982 }
9983
9984
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
9985 {
9986 return qe_invalid;
9987 }
9988
9989
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
9990 {
9991 return qe_invalid;
9992 }
9993
9994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
9995 {
9996 96 poundspr[i][spr_tile]=(int32_t)tile;
9997 96 poundspr[i][spr_flip]=(int32_t)flip;
9998 96 poundspr[i][spr_extend]=(int32_t)extend;
9999 96 }
10000 96 }
10001
10002
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tile,f,keepdata))
10003 {
10004 return qe_invalid;
10005 }
10006
10007 24 flip=0;
10008
10009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>0)
10010 {
10011
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&flip,f,keepdata))
10012 {
10013 return qe_invalid;
10014 }
10015 24 }
10016
10017
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&extend,f,keepdata))
10018 {
10019 return qe_invalid;
10020 }
10021
10022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(keepdata)
10023 {
10024 24 castingspr[spr_tile]=(int32_t)tile;
10025 24 castingspr[spr_flip]=(int32_t)flip;
10026 24 castingspr[spr_extend]=(int32_t)extend;
10027 24 }
10028
10029
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(v_herosprites>0)
10030 {
10031 24 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10032
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
72 for(int32_t i=0; i<2; i++)
10033 {
10034
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 48 times.
144 for(int32_t j=0; j<num_holdsprs; j++)
10035 {
10036
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
10037 {
10038 return qe_invalid;
10039 }
10040
10041
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10042 {
10043 return qe_invalid;
10044 }
10045
10046
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10047 {
10048 return qe_invalid;
10049 }
10050
10051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10052 {
10053 96 holdspr[i][j][spr_tile]=(int32_t)tile;
10054 96 holdspr[i][j][spr_flip]=(int32_t)flip;
10055 96 holdspr[i][j][spr_extend]=(int32_t)extend;
10056 96 }
10057 96 }
10058 48 }
10059 24 }
10060 else
10061 {
10062 for(int32_t i=0; i<2; i++)
10063 {
10064 if(!p_igetw(&tile,f,keepdata))
10065 {
10066 return qe_invalid;
10067 }
10068
10069 if(!p_igetw(&tile2,f,keepdata))
10070 {
10071 return qe_invalid;
10072 }
10073
10074 if(!p_getc(&extend,f,keepdata))
10075 {
10076 return qe_invalid;
10077 }
10078
10079 if(keepdata)
10080 {
10081 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10082 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10083 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10084 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10085 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10086 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10087 }
10088 }
10089 }
10090
10091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>2)
10092 {
10093
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10094 {
10095
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
10096 {
10097 return qe_invalid;
10098 }
10099
10100
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10101 {
10102 return qe_invalid;
10103 }
10104
10105
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10106 {
10107 return qe_invalid;
10108 }
10109
10110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10111 {
10112 96 jumpspr[i][spr_tile]=(int32_t)tile;
10113 96 jumpspr[i][spr_flip]=(int32_t)flip;
10114 96 jumpspr[i][spr_extend]=(int32_t)extend;
10115 96 }
10116 96 }
10117 24 }
10118
10119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>3)
10120 {
10121
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10122 {
10123
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&tile,f,keepdata))
10124 {
10125 return qe_invalid;
10126 }
10127
10128
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10129 {
10130 return qe_invalid;
10131 }
10132
10133
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10134 {
10135 return qe_invalid;
10136 }
10137
10138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10139 {
10140 96 chargespr[i][spr_tile]=(int32_t)tile;
10141 96 chargespr[i][spr_flip]=(int32_t)flip;
10142 96 chargespr[i][spr_extend]=(int32_t)extend;
10143 96 }
10144 96 }
10145 24 }
10146
10147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>4)
10148 {
10149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!p_getc(&dummy_byte,f,keepdata))
10150 {
10151 return qe_invalid;
10152 }
10153
10154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(keepdata)
10155 {
10156 24 zinit.hero_swim_speed=(byte)dummy_byte;
10157 24 }
10158 24 }
10159
10160
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(keepdata)
10161 {
10162 24 memset(frozenspr, 0, sizeof(frozenspr));
10163 24 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10164 24 memset(onfirespr, 0, sizeof(onfirespr));
10165 24 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10166 24 memset(diggingspr, 0, sizeof(diggingspr));
10167 24 memset(usingrodspr, 0, sizeof(usingrodspr));
10168 24 memset(usingcanespr, 0, sizeof(usingcanespr));
10169 24 memset(pushingspr, 0, sizeof(pushingspr));
10170 24 memset(liftingspr, 0, sizeof(liftingspr));
10171 24 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10172 24 memset(stunnedspr, 0, sizeof(stunnedspr));
10173 24 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10174 24 memset(fallingspr, 0, sizeof(fallingspr));
10175 24 memset(shockedspr, 0, sizeof(shockedspr));
10176 24 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10177 24 memset(pullswordspr, 0, sizeof(pullswordspr));
10178 24 memset(readingspr, 0, sizeof(readingspr));
10179 24 memset(slash180spr, 0, sizeof(slash180spr));
10180 24 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10181 24 memset(dashspr, 0, sizeof(dashspr));
10182 24 memset(bonkspr, 0, sizeof(bonkspr));
10183 24 memset(medallionsprs, 0, sizeof(medallionsprs));
10184 24 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10185 24 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10186
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10187 {
10188
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 96 times.
384 for(int32_t p = 0; p < 3; ++p)
10189 {
10190 288 drowningspr[q][p] = divespr[q][p];
10191 288 drowning_lavaspr[q][p] = divespr[q][p];
10192 288 }
10193 96 }
10194 24 memset(sideswimspr, 0, sizeof(sideswimspr));
10195 24 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10196 24 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10197 24 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10198 24 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10199 24 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10200 24 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10201 24 }
10202 24 }
10203
10204 24 return 0;
10205 24 }
10206
10207 170 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10208 {
10209 170 arr[spr_tile] = tile;
10210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 arr[spr_flip] = (flip > 3 ? 0 : flip);
10211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 arr[spr_extend] = (ext > 2 ? 0 : ext);
10212 170 }
10213 //Used to read the player sprites as int32_t, not word.
10214 1 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10215 {
10216 //these are here to bypass compiler warnings about unused arguments
10217 1 cv_herosprites=cv_herosprites;
10218
10219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(keepdata)
10220 {
10221 1 zinit.hero_swim_speed=67; //default
10222 1 setupherotiles(zinit.heroAnimationStyle);
10223 1 setupherodefenses();
10224 1 setupherooffsets();
10225 1 }
10226
10227 int32_t tile, tile2;
10228 byte flip, extend, dummy_byte;
10229
10230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(v_herosprites>=0)
10231 {
10232
10233
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
10234 {
10235
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10236 {
10237 return qe_invalid;
10238 }
10239
10240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10241 {
10242 return qe_invalid;
10243 }
10244
10245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10246 {
10247 return qe_invalid;
10248 }
10249
10250 4 if(keepdata)
10251 {
10252 4 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10253 4 }
10254 4 }
10255
10256
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
10257 {
10258
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10259 {
10260 return qe_invalid;
10261 }
10262
10263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10264 {
10265 return qe_invalid;
10266 }
10267
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10269 {
10270 return qe_invalid;
10271 }
10272
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10274 {
10275 4 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10276 4 }
10277 4 }
10278
10279
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
10280 {
10281
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10282 {
10283 return qe_invalid;
10284 }
10285
10286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10287 {
10288 return qe_invalid;
10289 }
10290
10291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10292 {
10293 return qe_invalid;
10294 }
10295
10296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10297 {
10298 4 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10299 4 }
10300 4 }
10301
10302
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
10303 {
10304
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10305 {
10306 return qe_invalid;
10307 }
10308
10309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10310 {
10311 return qe_invalid;
10312 }
10313
10314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10315 {
10316 return qe_invalid;
10317 }
10318
10319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10320 {
10321 4 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10322 4 }
10323 4 }
10324
10325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(v_herosprites>1)
10326 {
10327
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
10328 {
10329
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10330 {
10331 return qe_invalid;
10332 }
10333
10334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10335 {
10336 return qe_invalid;
10337 }
10338
10339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10340 {
10341 return qe_invalid;
10342 }
10343
10344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10345 {
10346 4 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10347 4 }
10348 4 }
10349 1 }
10350
10351
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
10352 {
10353
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10354 {
10355 return qe_invalid;
10356 }
10357
10358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10359 {
10360 return qe_invalid;
10361 }
10362
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10364 {
10365 return qe_invalid;
10366 }
10367
10368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10369 {
10370 4 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10371 4 }
10372 4 }
10373
10374
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
10375 {
10376
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10377 {
10378 return qe_invalid;
10379 }
10380
10381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10382 {
10383 return qe_invalid;
10384 }
10385
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10392 {
10393 4 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10394 4 }
10395 4 }
10396
10397
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&tile,f,keepdata))
10398 {
10399 return qe_invalid;
10400 }
10401
10402 1 flip=0;
10403
10404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(v_herosprites>0)
10405 {
10406
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&flip,f,keepdata))
10407 {
10408 return qe_invalid;
10409 }
10410 1 }
10411
10412
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&extend,f,keepdata))
10413 {
10414 return qe_invalid;
10415 }
10416
10417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(keepdata)
10418 {
10419 1 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10420 1 }
10421
10422
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(v_herosprites>0)
10423 {
10424 1 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10425
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for(int32_t i=0; i<2; i++)
10426 {
10427
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for(int32_t j=0; j<num_holdsprs; j++)
10428 {
10429
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_igetl(&tile,f,keepdata))
10430 {
10431 return qe_invalid;
10432 }
10433
10434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!p_getc(&flip,f,keepdata))
10435 {
10436 return qe_invalid;
10437 }
10438
10439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!p_getc(&extend,f,keepdata))
10440 {
10441 return qe_invalid;
10442 }
10443
10444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(keepdata)
10445 {
10446 6 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10447 6 }
10448 6 }
10449 2 }
10450 1 }
10451 else
10452 {
10453 for(int32_t i=0; i<2; i++)
10454 {
10455 if(!p_igetl(&tile,f,keepdata))
10456 {
10457 return qe_invalid;
10458 }
10459
10460 if(!p_igetl(&tile2,f,keepdata))
10461 {
10462 return qe_invalid;
10463 }
10464
10465 if(!p_getc(&extend,f,keepdata))
10466 {
10467 return qe_invalid;
10468 }
10469
10470 if(keepdata)
10471 {
10472 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10473 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10474 }
10475 }
10476 }
10477
10478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(v_herosprites>2)
10479 {
10480
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
10481 {
10482
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10483 {
10484 return qe_invalid;
10485 }
10486
10487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10488 {
10489 return qe_invalid;
10490 }
10491
10492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10493 {
10494 return qe_invalid;
10495 }
10496
10497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10498 {
10499 4 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10500 4 }
10501 4 }
10502 1 }
10503
10504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(v_herosprites>3)
10505 {
10506
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
10507 {
10508
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10509 {
10510 return qe_invalid;
10511 }
10512
10513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10514 {
10515 return qe_invalid;
10516 }
10517
10518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10519 {
10520 return qe_invalid;
10521 }
10522
10523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10524 {
10525 4 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10526 4 }
10527 4 }
10528 1 }
10529
10530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(v_herosprites>4)
10531 {
10532
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&dummy_byte,f,keepdata))
10533 {
10534 return qe_invalid;
10535 }
10536
10537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(keepdata)
10538 {
10539 1 zinit.hero_swim_speed=(byte)dummy_byte;
10540 1 }
10541 1 }
10542
10543
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(v_herosprites>6)
10544 {
10545
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10546 {
10547
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10548 return qe_invalid;
10549
10550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10551 return qe_invalid;
10552
10553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10554 return qe_invalid;
10555
10556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10557 {
10558 4 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10559 4 }
10560 4 }
10561
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10562 {
10563
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10564 return qe_invalid;
10565
10566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10567 return qe_invalid;
10568
10569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10570 return qe_invalid;
10571
10572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10573 {
10574 4 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10575 4 }
10576 4 }
10577
10578
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10579 {
10580
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10581 return qe_invalid;
10582
10583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10584 return qe_invalid;
10585
10586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10587 return qe_invalid;
10588
10589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10590 {
10591 4 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10592 4 }
10593 4 }
10594
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10595 {
10596
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10597 return qe_invalid;
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10600 return qe_invalid;
10601
10602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10603 return qe_invalid;
10604
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10606 {
10607 4 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10608 4 }
10609 4 }
10610
10611
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10612 {
10613
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10614 return qe_invalid;
10615
10616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10617 return qe_invalid;
10618
10619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10620 return qe_invalid;
10621
10622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10623 {
10624 4 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10625 4 }
10626 4 }
10627
10628
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10629 {
10630
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10631 return qe_invalid;
10632
10633
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10634 return qe_invalid;
10635
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10637 return qe_invalid;
10638
10639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10640 {
10641 4 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10642 4 }
10643 4 }
10644
10645
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10646 {
10647
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10648 return qe_invalid;
10649
10650
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10651 return qe_invalid;
10652
10653
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10654 return qe_invalid;
10655
10656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10657 {
10658 4 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10659 4 }
10660 4 }
10661
10662
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10663 {
10664
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10665 return qe_invalid;
10666
10667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10668 return qe_invalid;
10669
10670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10671 return qe_invalid;
10672
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10674 {
10675 4 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10676 4 }
10677 4 }
10678
10679
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10680 {
10681
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10682 return qe_invalid;
10683
10684
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10685 return qe_invalid;
10686
10687
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10688 return qe_invalid;
10689
10690 4 byte frames = 0;
10691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(v_herosprites > 15)
10692 {
10693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&frames,f,keepdata))
10694 return qe_invalid;
10695 4 }
10696
10697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10698 {
10699 4 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10700 4 liftingspr[q][spr_frames] = frames;
10701 4 }
10702 4 }
10703
10704
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10705 {
10706
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10707 return qe_invalid;
10708
10709
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10710 return qe_invalid;
10711
10712
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10713 return qe_invalid;
10714
10715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10716 {
10717 4 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10718 4 }
10719 4 }
10720
10721
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10722 {
10723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetl(&tile,f,keepdata))
10724 return qe_invalid;
10725
10726
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10727 return qe_invalid;
10728
10729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10730 return qe_invalid;
10731
10732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10733 {
10734 4 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10735 4 }
10736 4 }
10737
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10738 {
10739
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10740 return qe_invalid;
10741
10742
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10743 return qe_invalid;
10744
10745
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10746 return qe_invalid;
10747
10748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10749 {
10750 4 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10751 4 }
10752 4 }
10753
10754
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10755 {
10756
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10757 return qe_invalid;
10758
10759
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10760 return qe_invalid;
10761
10762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10763 return qe_invalid;
10764
10765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10766 {
10767 4 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10768 4 }
10769 4 }
10770
10771
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10772 {
10773
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10774 return qe_invalid;
10775
10776
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10777 return qe_invalid;
10778
10779
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10780 return qe_invalid;
10781
10782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10783 {
10784 4 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10785 4 }
10786 4 }
10787
10788
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10789 {
10790
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10791 return qe_invalid;
10792
10793
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10794 return qe_invalid;
10795
10796
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10797 return qe_invalid;
10798
10799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10800 {
10801 4 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10802 4 }
10803 4 }
10804
10805
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10806 {
10807
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10808 return qe_invalid;
10809
10810
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10811 return qe_invalid;
10812
10813
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10814 return qe_invalid;
10815
10816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10817 {
10818 4 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10819 4 }
10820 4 }
10821
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10822 {
10823
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10824 return qe_invalid;
10825
10826
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10827 return qe_invalid;
10828
10829
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10830 return qe_invalid;
10831
10832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10833 {
10834 4 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10835 4 }
10836 4 }
10837
10838
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10839 {
10840
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10841 return qe_invalid;
10842
10843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
10844 return qe_invalid;
10845
10846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10847 return qe_invalid;
10848
10849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10850 {
10851 4 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10852 4 }
10853 4 }
10854
10855
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10856 {
10857
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10858 return qe_invalid;
10859
10860
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10861 return qe_invalid;
10862
10863
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10864 return qe_invalid;
10865
10866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10867 {
10868 4 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10869 4 }
10870 4 }
10871
10872
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10873 {
10874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetl(&tile,f,keepdata))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10878 return qe_invalid;
10879
10880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
10881 return qe_invalid;
10882
10883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10884 {
10885 4 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10886 4 }
10887 4 }
10888
10889
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10890 {
10891
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10892 return qe_invalid;
10893
10894
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10895 return qe_invalid;
10896
10897
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10898 return qe_invalid;
10899
10900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10901 {
10902 4 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10903 4 }
10904 4 }
10905
10906
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10907 {
10908
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10909 return qe_invalid;
10910
10911
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10912 return qe_invalid;
10913
10914
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10915 return qe_invalid;
10916
10917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10918 {
10919 4 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10920 4 }
10921 4 }
10922
10923
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10924 {
10925
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10926 return qe_invalid;
10927
10928
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&flip,f,keepdata))
10929 return qe_invalid;
10930
10931
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&extend,f,keepdata))
10932 return qe_invalid;
10933
10934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
10935 {
10936 4 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10937 4 }
10938 4 }
10939
10940
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10941 {
10942
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&tile,f,keepdata))
10943 return qe_invalid;
10944
10945
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&flip,f,keepdata))
10946 return qe_invalid;
10947
10948
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&extend,f,keepdata))
10949 return qe_invalid;
10950
10951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
10952 {
10953 3 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10954 3 }
10955 3 }
10956 1 }
10957 else if(keepdata)
10958 {
10959 memset(frozenspr, 0, sizeof(frozenspr));
10960 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10961 memset(onfirespr, 0, sizeof(onfirespr));
10962 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10963 memset(diggingspr, 0, sizeof(diggingspr));
10964 memset(usingrodspr, 0, sizeof(usingrodspr));
10965 memset(usingcanespr, 0, sizeof(usingcanespr));
10966 memset(pushingspr, 0, sizeof(pushingspr));
10967 memset(liftingspr, 0, sizeof(liftingspr));
10968 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10969 memset(stunnedspr, 0, sizeof(stunnedspr));
10970 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10971 memset(fallingspr, 0, sizeof(fallingspr));
10972 memset(shockedspr, 0, sizeof(shockedspr));
10973 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10974 memset(pullswordspr, 0, sizeof(pullswordspr));
10975 memset(readingspr, 0, sizeof(readingspr));
10976 memset(slash180spr, 0, sizeof(slash180spr));
10977 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10978 memset(dashspr, 0, sizeof(dashspr));
10979 memset(bonkspr, 0, sizeof(bonkspr));
10980 memset(medallionsprs, 0, sizeof(medallionsprs));
10981 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10982 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10983 for(int32_t q = 0; q < 4; ++q)
10984 {
10985 for(int32_t p = 0; p < 3; ++p)
10986 {
10987 drowningspr[q][p] = divespr[q][p];
10988 drowning_lavaspr[q][p] = divespr[q][p];
10989 }
10990 }
10991 }
10992
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (v_herosprites > 8)
10993 {
10994
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
10995 {
10996
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
10997 return qe_invalid;
10998
10999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
11000 return qe_invalid;
11001
11002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
11003 return qe_invalid;
11004
11005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
11006 {
11007 4 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11008 4 }
11009 4 }
11010 1 }
11011 else if (keepdata)
11012 {
11013 memset(sideswimspr, 0, sizeof(sideswimspr));
11014 }
11015
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (v_herosprites > 9)
11016 {
11017
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
11018 {
11019
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
11020 return qe_invalid;
11021
11022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
11023 return qe_invalid;
11024
11025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
11026 return qe_invalid;
11027
11028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
11029 {
11030 4 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11031 4 }
11032 4 }
11033
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
11034 {
11035
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
11036 return qe_invalid;
11037
11038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
11039 return qe_invalid;
11040
11041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
11042 return qe_invalid;
11043
11044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
11045 {
11046 4 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11047 4 }
11048 4 }
11049
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
11050 {
11051
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
11058 return qe_invalid;
11059
11060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
11061 {
11062 4 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11063 4 }
11064 4 }
11065
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
11066 {
11067
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
11068 return qe_invalid;
11069
11070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
11071 return qe_invalid;
11072
11073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
11074 return qe_invalid;
11075
11076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
11077 {
11078 4 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11079 4 }
11080 4 }
11081 1 }
11082 else if (keepdata)
11083 {
11084 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11085 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11086 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11087 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11088 }
11089
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (v_herosprites > 10)
11090 {
11091
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
11092 {
11093 int32_t hmr;
11094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetl(&hmr,f,keepdata))
11095 return qe_invalid;
11096
11097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
11098 {
11099 4 hammeroffsets[q] = hmr;
11100 4 }
11101 4 }
11102 1 }
11103 else if (keepdata)
11104 {
11105 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11106 }
11107
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (v_herosprites > 11)
11108 {
11109
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t q = 0; q < 3; ++q)
11110 {
11111
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&tile,f,keepdata))
11112 return qe_invalid;
11113
11114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!p_getc(&flip,f,keepdata))
11115 return qe_invalid;
11116
11117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!p_getc(&extend,f,keepdata))
11118 return qe_invalid;
11119
11120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
11121 {
11122 3 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11123 3 }
11124 3 }
11125 1 }
11126 else if (keepdata)
11127 {
11128 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11129 }
11130
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (v_herosprites > 12)
11131 {
11132
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&tile,f,keepdata))
11133 return qe_invalid;
11134
11135
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&flip,f,keepdata))
11136 return qe_invalid;
11137
11138
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&extend,f,keepdata))
11139 return qe_invalid;
11140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (keepdata)
11141 {
11142 1 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11143 1 }
11144
11145 1 }
11146 else if (keepdata)
11147 {
11148 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11149 }
11150
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (v_herosprites > 13)
11151 {
11152
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
11153 {
11154
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
11155 return qe_invalid;
11156
11157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
11158 return qe_invalid;
11159
11160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
11161 return qe_invalid;
11162
11163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
11164 {
11165 4 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11166 4 }
11167 4 }
11168 1 }
11169 else if (keepdata)
11170 {
11171 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11172 }
11173
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (v_herosprites > 14)
11174 {
11175
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t q = 0; q < 4; ++q)
11176 {
11177
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetl(&tile,f,keepdata))
11178 return qe_invalid;
11179
11180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&flip,f,keepdata))
11181 return qe_invalid;
11182
11183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&extend,f,keepdata))
11184 return qe_invalid;
11185
11186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata)
11187 {
11188 4 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11189 4 }
11190 4 }
11191 1 }
11192 else if (keepdata)
11193 {
11194 memset(revslashspr, 0, sizeof(revslashspr));
11195 }
11196
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (v_herosprites > 7)
11197 {
11198 1 int32_t num_defense = wMax;
11199 1 byte def = 0;
11200
11201 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11202 /*if(v_herosprites > [x])
11203 * {
11204 * num_defense = 146 //value of wMax on version 8
11205 * }
11206 */
11207
11208
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 1 times.
147 for (int32_t q = 0; q < num_defense; q++)
11209 {
11210
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 if (!p_getc(&def, f, keepdata))
11211 return qe_invalid;
11212
11213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if (keepdata)
11214 {
11215 146 hero_defence[q] = def;
11216 146 }
11217 146 }
11218 1 }
11219 else if (keepdata)
11220 {
11221 int32_t num_defense = wMax;
11222 for (int32_t q = 0; q < num_defense; q++)
11223 {
11224 hero_defence[q] = 0;
11225 }
11226 }
11227 1 }
11228
11229 1 return 0;
11230 1 }
11231
11232
11233 25 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11234 {
11235 //these are here to bypass compiler warnings about unused arguments
11236 25 Header=Header;
11237
11238 dword dummy;
11239 25 word s_version=0, s_cversion=0;
11240
11241 //section version info
11242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&s_version,f,true))
11243 {
11244 return qe_invalid;
11245 }
11246
11247 25 FFCore.quest_format[vHeroSprites] = s_version;
11248
11249 //al_trace("Player sprites version %d\n", s_version);
11250
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
11251 {
11252 return qe_invalid;
11253 }
11254
11255 //section size
11256
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
11257 {
11258 return qe_invalid;
11259 }
11260
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( s_version >= 6 )
11261 {
11262 //al_trace("Reading Player Sprites v6\n");
11263 1 return readherosprites3(f, s_version, dummy, keepdata);
11264 }
11265 24 else return readherosprites2(f, s_version, dummy, keepdata);
11266 25 }
11267
11268 25 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11269 {
11270 int32_t dummy;
11271 25 word s_version=0, s_cversion=0;
11272
11273 //section version info
11274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&s_version,f,true))
11275 {
11276 return qe_invalid;
11277 }
11278
11279 25 FFCore.quest_format[vSubscreen] = s_version;
11280
11281 //al_trace("Subscreens version %d\n", s_version);
11282
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
11283 {
11284 return qe_invalid;
11285 }
11286
11287 //section size
11288
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
11289 {
11290 return qe_invalid;
11291 }
11292
11293 //finally... section data
11294
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 25 times.
3225 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11295 {
11296 3200 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11297
11298
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(ret!=0) return ret;
11299 3200 }
11300
11301 25 return 0;
11302 25 }
11303
11304 3200 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11305 {
11306 3200 int32_t numsub=0;
11307 3200 byte temp_ss=0;
11308 subscreen_object temp_sub_stack;
11309 3200 subscreen_object *temp_sub = &temp_sub_stack;
11310
11311 char tempname[64];
11312
11313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 if(!pfread(tempname,64,f,true))
11314 {
11315 return qe_invalid;
11316 }
11317
11318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 if(s_version > 1)
11319 {
11320
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&temp_ss,f,keepdata))
11321 {
11322 return qe_invalid;
11323 }
11324 3200 }
11325
11326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 if(s_version < 4)
11327 {
11328 uint8_t tmp=0;
11329
11330 if(!p_getc(&tmp,f,true))
11331 {
11332 return qe_invalid;
11333 }
11334
11335 numsub = (int32_t)tmp;
11336 }
11337 else
11338 {
11339 word tmp;
11340
11341
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_igetw(&tmp, f, true))
11342 {
11343 return qe_invalid;
11344 }
11345
11346 3200 numsub = (int32_t)tmp;
11347 }
11348
11349 int32_t j;
11350
11351
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5967 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 3200 times.
5967 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11352 {
11353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(keepdata)
11354 {
11355 2767 memset(temp_sub,0,sizeof(subscreen_object));
11356
11357
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 2443 times.
2767 switch(custom_subscreen[i].objects[j].type)
11358 {
11359 case ssoTEXT:
11360 case ssoTEXTBOX:
11361 case ssoCURRENTITEMTEXT:
11362 case ssoCURRENTITEMCLASSTEXT:
11363
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 324 times.
✗ Branch 3 not taken.
324 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11364
11365 //fall through
11366 default:
11367 2767 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11368 2767 break;
11369 }
11370 2767 }
11371
11372
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_getc(&(temp_sub->type),f,true))
11373 {
11374 return qe_invalid;
11375 }
11376
11377
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_getc(&(temp_sub->pos),f,keepdata))
11378 {
11379 return qe_invalid;
11380 }
11381
11382
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(s_version < 5)
11383 {
11384 switch(temp_sub->pos)
11385 {
11386 case 0:
11387 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11388 break;
11389
11390 case 1:
11391 temp_sub->pos = sspUP;
11392 break;
11393
11394 case 2:
11395 temp_sub->pos = sspDOWN;
11396 break;
11397
11398 default:
11399 temp_sub->pos = 0;
11400 }
11401 }
11402
11403
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetw(&(temp_sub->x),f,keepdata))
11404 {
11405 return qe_invalid;
11406 }
11407
11408
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetw(&(temp_sub->y),f,keepdata))
11409 {
11410 return qe_invalid;
11411 }
11412
11413
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetw(&(temp_sub->w),f,keepdata))
11414 {
11415 return qe_invalid;
11416 }
11417
11418
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetw(&(temp_sub->h),f,keepdata))
11419 {
11420 return qe_invalid;
11421 }
11422
11423
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11424 {
11425 return qe_invalid;
11426 }
11427
11428
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11429 {
11430 return qe_invalid;
11431 }
11432
11433
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11434 {
11435 return qe_invalid;
11436 }
11437
11438
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11439 {
11440 return qe_invalid;
11441 }
11442
11443
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11444 {
11445 return qe_invalid;
11446 }
11447
11448
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11449 {
11450 return qe_invalid;
11451 }
11452
11453
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11454 {
11455 return qe_invalid;
11456 }
11457
11458
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11459 {
11460 return qe_invalid;
11461 }
11462
11463
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11464 {
11465 return qe_invalid;
11466 }
11467
11468
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11469 {
11470 return qe_invalid;
11471 }
11472
11473
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11474 {
11475 return qe_invalid;
11476 }
11477
11478
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11479 {
11480 return qe_invalid;
11481 }
11482
11483
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11484 {
11485 return qe_invalid;
11486 }
11487
11488
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11489 {
11490 return qe_invalid;
11491 }
11492
11493
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11494 {
11495 return qe_invalid;
11496 }
11497
11498
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11499 {
11500 return qe_invalid;
11501 }
11502
11503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(s_version < 2)
11504 {
11505 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11506 {
11507 return qe_invalid;
11508 }
11509
11510 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11511 {
11512 return qe_invalid;
11513 }
11514
11515 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11516 {
11517 return qe_invalid;
11518 }
11519 }
11520 else
11521 {
11522
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_getc(&(temp_sub->speed),f,keepdata))
11523 {
11524 return qe_invalid;
11525 }
11526
11527
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_getc(&(temp_sub->delay),f,keepdata))
11528 {
11529 return qe_invalid;
11530 }
11531
11532
1/2
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
2767 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11533 {
11534 return qe_invalid;
11535 }
11536 }
11537
11538 2767 int32_t temp_size=0;
11539
11540 // bool deletets = false;
11541
4/4
✓ Branch 0 taken 1225 times.
✓ Branch 1 taken 393 times.
✓ Branch 2 taken 1101 times.
✓ Branch 3 taken 48 times.
2767 switch(temp_sub->type)
11542 {
11543 case ssoTEXT:
11544 case ssoTEXTBOX:
11545 case ssoCURRENTITEMTEXT:
11546 case ssoCURRENTITEMCLASSTEXT:
11547 word temptempsize;
11548 /*uint8_t temp1;
11549 uint8_t temp2;
11550 temp2 = 0;
11551 if(!p_getc(&temp1,f,true))
11552 {
11553 return qe_invalid;
11554 }
11555 if(temp1)
11556 {
11557
11558 if(!p_getc(&temp2,f,true))
11559 {
11560 return qe_invalid;
11561 }
11562 }*/
11563
11564
1/2
✓ Branch 0 taken 393 times.
✗ Branch 1 not taken.
393 if(!p_igetw(&temptempsize,f,true))
11565 {
11566 return qe_invalid;
11567 }
11568
11569 //temptempsize = temp1 + (temp2 << 8);
11570 393 temp_size = (int32_t)temptempsize;
11571
11572 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393 times.
393 if(keepdata)
11574 {
11575 393 uint32_t char_length = temp_size+1;
11576 393 temp_sub->dp1 = new char[char_length]; //memory not freed
11577
11578 //deletets = true; //obsolete
11579 393 }
11580
11581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393 times.
393 if(temp_size)
11582 {
11583
1/2
✓ Branch 0 taken 393 times.
✗ Branch 1 not taken.
393 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11584 {
11585 return qe_invalid;
11586 }
11587 393 }
11588
11589 393 break;
11590
11591 case ssoLIFEMETER:
11592
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11593 temp_sub->d3 = 1;
11594
11595
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11596 {
11597 return qe_invalid;
11598 }
11599
11600 48 break;
11601
11602
11603 case ssoCURRENTITEM:
11604
11605
1/2
✓ Branch 0 taken 1225 times.
✗ Branch 1 not taken.
1225 if(s_version < 6)
11606 {
11607 switch(temp_sub->d1)
11608 {
11609 case ssiBOMB:
11610 temp_sub->d1 = itype_bomb;
11611 break;
11612
11613 case ssiSWORD:
11614 temp_sub->d1 = itype_sword;
11615 break;
11616
11617 case ssiSHIELD:
11618 temp_sub->d1 = itype_shield;
11619 break;
11620
11621 case ssiCANDLE:
11622 temp_sub->d1 = itype_candle;
11623 break;
11624
11625 case ssiLETTER:
11626 temp_sub->d1 = itype_letter;
11627 break;
11628
11629 case ssiPOTION:
11630 temp_sub->d1 = itype_potion;
11631 break;
11632
11633 case ssiLETTERPOTION:
11634 temp_sub->d1 = itype_letterpotion;
11635 break;
11636
11637 case ssiBOW:
11638 temp_sub->d1 = itype_bow;
11639 break;
11640
11641 case ssiARROW:
11642 temp_sub->d1 = itype_arrow;
11643 break;
11644
11645 case ssiBOWANDARROW:
11646 temp_sub->d1 = itype_bowandarrow;
11647 break;
11648
11649 case ssiBAIT:
11650 temp_sub->d1 = itype_bait;
11651 break;
11652
11653 case ssiRING:
11654 temp_sub->d1 = itype_ring;
11655 break;
11656
11657 case ssiBRACELET:
11658 temp_sub->d1 = itype_bracelet;
11659 break;
11660
11661 case ssiMAP:
11662 temp_sub->d1 = itype_map;
11663 break;
11664
11665 case ssiCOMPASS:
11666 temp_sub->d1 = itype_compass;
11667 break;
11668
11669 case ssiBOSSKEY:
11670 temp_sub->d1 = itype_bosskey;
11671 break;
11672
11673 case ssiMAGICKEY:
11674 temp_sub->d1 = itype_magickey;
11675 break;
11676
11677 case ssiBRANG:
11678 temp_sub->d1 = itype_brang;
11679 break;
11680
11681 case ssiWAND:
11682 temp_sub->d1 = itype_wand;
11683 break;
11684
11685 case ssiRAFT:
11686 temp_sub->d1 = itype_raft;
11687 break;
11688
11689 case ssiLADDER:
11690 temp_sub->d1 = itype_ladder;
11691 break;
11692
11693 case ssiWHISTLE:
11694 temp_sub->d1 = itype_whistle;
11695 break;
11696
11697 case ssiBOOK:
11698 temp_sub->d1 = itype_book;
11699 break;
11700
11701 case ssiWALLET:
11702 temp_sub->d1 = itype_wallet;
11703 break;
11704
11705 case ssiSBOMB:
11706 temp_sub->d1 = itype_sbomb;
11707 break;
11708
11709 case ssiHCPIECE:
11710 temp_sub->d1 = itype_heartpiece;
11711 break;
11712
11713 case ssiAMULET:
11714 temp_sub->d1 = itype_amulet;
11715 break;
11716
11717 case ssiFLIPPERS:
11718 temp_sub->d1 = itype_flippers;
11719 break;
11720
11721 case ssiHOOKSHOT:
11722 temp_sub->d1 = itype_hookshot;
11723 break;
11724
11725 case ssiLENS:
11726 temp_sub->d1 = itype_lens;
11727 break;
11728
11729 case ssiHAMMER:
11730 temp_sub->d1 = itype_hammer;
11731 break;
11732
11733 case ssiBOOTS:
11734 temp_sub->d1 = itype_boots;
11735 break;
11736
11737 case ssiDINSFIRE:
11738 temp_sub->d1 = itype_dinsfire;
11739 break;
11740
11741 case ssiFARORESWIND:
11742 temp_sub->d1 = itype_faroreswind;
11743 break;
11744
11745 case ssiNAYRUSLOVE:
11746 temp_sub->d1 = itype_nayruslove;
11747 break;
11748
11749 case ssiQUIVER:
11750 temp_sub->d1 = itype_quiver;
11751 break;
11752
11753 case ssiBOMBBAG:
11754 temp_sub->d1 = itype_bombbag;
11755 break;
11756
11757 case ssiCBYRNA:
11758 temp_sub->d1 = itype_cbyrna;
11759 break;
11760
11761 case ssiROCS:
11762 temp_sub->d1 = itype_rocs;
11763 break;
11764
11765 case ssiHOVERBOOTS:
11766 temp_sub->d1 = itype_hoverboots;
11767 break;
11768
11769 case ssiSPINSCROLL:
11770 temp_sub->d1 = itype_spinscroll;
11771 break;
11772
11773 case ssiCROSSSCROLL:
11774 temp_sub->d1 = itype_crossscroll;
11775 break;
11776
11777 case ssiQUAKESCROLL:
11778 temp_sub->d1 = itype_quakescroll;
11779 break;
11780
11781 case ssiWHISPRING:
11782 temp_sub->d1 = itype_whispring;
11783 break;
11784
11785 case ssiCHARGERING:
11786 temp_sub->d1 = itype_chargering;
11787 break;
11788
11789 case ssiPERILSCROLL:
11790 temp_sub->d1 = itype_perilscroll;
11791 break;
11792
11793 case ssiWEALTHMEDAL:
11794 temp_sub->d1 = itype_wealthmedal;
11795 break;
11796
11797 case ssiHEARTRING:
11798 temp_sub->d1 = itype_heartring;
11799 break;
11800
11801 case ssiMAGICRING:
11802 temp_sub->d1 = itype_magicring;
11803 break;
11804
11805 case ssiSPINSCROLL2:
11806 temp_sub->d1 = itype_spinscroll2;
11807 break;
11808
11809 case ssiQUAKESCROLL2:
11810 temp_sub->d1 = itype_quakescroll2;
11811 break;
11812
11813 case ssiAGONY:
11814 temp_sub->d1 = itype_agony;
11815 break;
11816
11817 case ssiSTOMPBOOTS:
11818 temp_sub->d1 = itype_stompboots;
11819 break;
11820
11821 case ssiWHIMSICALRING:
11822 temp_sub->d1 = itype_whimsicalring;
11823 break;
11824
11825 case ssiPERILRING:
11826 temp_sub->d1 = itype_perilring;
11827 break;
11828
11829 default:
11830 temp_sub->d1 += itype_custom1 - ssiMAX;
11831 }
11832 }
11833
11834 //fall-through
11835 default:
11836
1/2
✓ Branch 0 taken 2326 times.
✗ Branch 1 not taken.
2326 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11837 {
11838 return qe_invalid;
11839 }
11840
11841 2326 break;
11842 }
11843
11844
2/2
✓ Branch 0 taken 543 times.
✓ Branch 1 taken 2224 times.
2767 if(s_version < 7)
11845 {
11846
1/3
✓ Branch 0 taken 2224 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2224 switch(temp_sub->type)
11847 {
11848 case ssoMAGICGAUGE:
11849 {
11850 if(!temp_sub->d9)
11851 temp_sub->d9 = -1; //-1 now represents 'always'
11852 break;
11853 }
11854 case ssoLIFEGAUGE:
11855 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11856 break;
11857 }
11858 2224 }
11859
11860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(keepdata)
11861 {
11862
3/3
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 2328 times.
✓ Branch 2 taken 46 times.
2767 switch(temp_sub->type)
11863 {
11864 case ssoTEXT:
11865 case ssoTEXTBOX:
11866 case ssoCURRENTITEMTEXT:
11867 case ssoCURRENTITEMCLASSTEXT:
11868
1/4
✓ Branch 0 taken 393 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
393 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11869
11870 393 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11871 393 custom_subscreen[i].objects[j].dp1 = NULL;
11872 393 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
11873 393 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
11874 393 break;
11875
11876 case ssoCOUNTER:
11877
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(s_version<3)
11878 {
11879 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11880 temp_sub->d8=0;
11881 }
11882
11883 default:
11884 2374 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11885 2374 break;
11886 }
11887
11888 2767 strcpy(custom_subscreen[i].name, tempname);
11889 2767 custom_subscreen[i].ss_type = temp_ss;
11890 2767 }
11891 2767 }
11892
11893
2/2
✓ Branch 0 taken 816433 times.
✓ Branch 1 taken 3200 times.
819633 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11894 {
11895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816433 times.
816433 if(keepdata)
11896 {
11897 //clear all unused object in this subscreen -DD
11898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816433 times.
816433 switch(custom_subscreen[i].objects[j].type)
11899 {
11900 case ssoTEXT:
11901 case ssoTEXTBOX:
11902 case ssoCURRENTITEMTEXT:
11903 case ssoCURRENTITEMCLASSTEXT:
11904 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11905
11906 //fall through
11907 default:
11908 816433 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11909 816433 break;
11910 }
11911 816433 }
11912 816433 }
11913
11914 3200 return 0;
11915 3200 }
11916
11917 1536 void reset_subscreen(subscreen_group *tempss)
11918 {
11919
2/2
✓ Branch 0 taken 393216 times.
✓ Branch 1 taken 1536 times.
394752 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11920 {
11921
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 393138 times.
393216 switch(tempss->objects[i].type)
11922 {
11923 case ssoTEXT:
11924 case ssoTEXTBOX:
11925 case ssoCURRENTITEMTEXT:
11926 case ssoCURRENTITEMCLASSTEXT:
11927
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
78 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11928
11929 //fall through
11930 default:
11931 393216 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11932 393216 break;
11933 }
11934 393216 }
11935 1536 }
11936
11937 12 void reset_subscreens()
11938 {
11939
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11940 {
11941 1536 reset_subscreen(&custom_subscreen[i]);
11942 1536 }
11943 12 }
11944
11945 12 int32_t setupsubscreens()
11946 {
11947 12 reset_subscreens();
11948 12 int32_t tempsubscreen=zinit.subscreen;
11949 subscreen_object *tempsub;
11950
11951
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(tempsubscreen>=ssdtMAX)
11952 {
11953 tempsubscreen=0;
11954 }
11955
11956
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 switch(tempsubscreen)
11957 {
11958 case ssdtOLD:
11959 case ssdtNEWSUBSCR:
11960 case ssdtREV2:
11961 case ssdtBSZELDA:
11962 case ssdtBSZELDAMODIFIED:
11963 case ssdtBSZELDAENHANCED:
11964 case ssdtBSZELDACOMPLETE:
11965 {
11966 12 tempsub = default_subscreen_active[tempsubscreen][0];
11967 int32_t i;
11968
11969
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 12 times.
792 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11970 {
11971
2/3
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 740 times.
✗ Branch 2 not taken.
780 switch(tempsub[i].type)
11972 {
11973 case ssoTEXT:
11974 case ssoTEXTBOX:
11975 case ssoCURRENTITEMTEXT:
11976 case ssoCURRENTITEMCLASSTEXT:
11977
1/4
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11978
11979 40 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11980 40 custom_subscreen[0].objects[i].dp1 = NULL;
11981 40 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11982 40 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11983 40 break;
11984
11985 case ssoLIFEMETER:
11986 {
11987 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11988
11989 if(get_bit(deprecated_rules, 12) != 0)
11990 custom_subscreen[0].objects[i].d3=1;
11991 else
11992 custom_subscreen[0].objects[i].d3=0;
11993
11994 break;
11995 }
11996 /*
11997 case ssoTRIFRAME:
11998 {
11999 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12000 custom_subscreen[0].objects[i].d1 = 8594;
12001 custom_subscreen[0].objects[i].d2 = 8;
12002 custom_subscreen[0].objects[i].d3 = 8771;
12003 custom_subscreen[0].objects[i].d4 = 8;
12004 custom_subscreen[0].objects[i].d5 = 1;
12005 custom_subscreen[0].objects[i].d6 = 1;
12006 break;
12007 }*/
12008
12009 default:
12010 740 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12011 740 break;
12012 }
12013 780 }
12014
12015 12 custom_subscreen[0].ss_type=sstACTIVE;
12016 12 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12017 12 tempsub = default_subscreen_active[tempsubscreen][1];
12018
12019
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 12 times.
792 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12020 {
12021
2/3
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 728 times.
✗ Branch 2 not taken.
780 switch(tempsub[i].type)
12022 {
12023 case ssoTEXT:
12024 case ssoTEXTBOX:
12025 case ssoCURRENTITEMTEXT:
12026 case ssoCURRENTITEMCLASSTEXT:
12027
1/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12028
12029 52 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12030 52 custom_subscreen[1].objects[i].dp1 = NULL;
12031 52 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12032 52 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12033 52 break;
12034
12035 case ssoLIFEMETER:
12036 {
12037 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12038
12039 if(get_bit(deprecated_rules, 12) != 0)
12040 custom_subscreen[1].objects[i].d3=1;
12041 else
12042 custom_subscreen[1].objects[i].d3=0;
12043
12044 break;
12045 }
12046 /*
12047 case ssoTRIFRAME:
12048 {
12049 custom_subscreen[1].objects[i].d1 = 8594;
12050 custom_subscreen[1].objects[i].d2 = 8;
12051 custom_subscreen[1].objects[i].d3 = 8771;
12052 custom_subscreen[1].objects[i].d4 = 8;
12053 custom_subscreen[1].objects[i].d5 = 1;
12054 custom_subscreen[1].objects[i].d6 = 1;
12055 break;
12056 }*/
12057
12058 default:
12059 728 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12060 728 break;
12061 }
12062 780 }
12063
12064 12 custom_subscreen[1].ss_type=sstACTIVE;
12065 12 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12066 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12067 12 tempsub = default_subscreen_passive[tempsubscreen][0];
12068
12069
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
✓ Branch 2 taken 240 times.
✓ Branch 3 taken 12 times.
252 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12070 {
12071
3/3
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 12 times.
240 switch(tempsub[i].type)
12072 {
12073 case ssoTEXT:
12074 case ssoTEXTBOX:
12075 case ssoCURRENTITEMTEXT:
12076 case ssoCURRENTITEMCLASSTEXT:
12077
1/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12078
12079 36 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12080 36 custom_subscreen[2].objects[i].dp1 = NULL;
12081 36 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12082 36 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12083 36 break;
12084
12085 case ssoLIFEMETER:
12086 {
12087 12 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12088
12089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(get_bit(deprecated_rules, 12) != 0)
12090 custom_subscreen[2].objects[i].d3=1;
12091 else
12092 12 custom_subscreen[2].objects[i].d3=0;
12093
12094 12 break;
12095 }
12096
12097 default:
12098 192 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12099 192 break;
12100 }
12101 240 }
12102
12103 12 custom_subscreen[2].ss_type=sstPASSIVE;
12104 12 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12105 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12106 12 tempsub = default_subscreen_passive[tempsubscreen][1];
12107
12108
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
✓ Branch 2 taken 228 times.
✓ Branch 3 taken 12 times.
240 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12109 {
12110
3/3
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 12 times.
228 switch(tempsub[i].type)
12111 {
12112 case ssoTEXT:
12113 case ssoTEXTBOX:
12114 case ssoCURRENTITEMTEXT:
12115 case ssoCURRENTITEMCLASSTEXT:
12116
1/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12117
12118 36 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12119 36 custom_subscreen[3].objects[i].dp1 = NULL;
12120 36 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12121 36 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12122 36 break;
12123
12124 case ssoLIFEMETER:
12125 {
12126 12 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12127
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(get_bit(deprecated_rules, 12) != 0)
12129 custom_subscreen[3].objects[i].d3=1;
12130 else
12131 12 custom_subscreen[3].objects[i].d3=0;
12132
12133 12 break;
12134 }
12135
12136 default:
12137 180 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12138 180 break;
12139 }
12140 228 }
12141
12142 12 custom_subscreen[3].ss_type=sstPASSIVE;
12143 12 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12144 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12145 12 break;
12146 }
12147
12148 case ssdtZ3:
12149 {
12150 tempsub = z3_active_a;
12151 int32_t i;
12152
12153 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12154 {
12155 switch(tempsub[i].type)
12156 {
12157 case ssoTEXT:
12158 case ssoTEXTBOX:
12159 case ssoCURRENTITEMTEXT:
12160 case ssoCURRENTITEMCLASSTEXT:
12161 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12162
12163 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12164 custom_subscreen[0].objects[i].dp1 = NULL;
12165 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12166 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12167 break;
12168
12169 case ssoLIFEMETER:
12170 {
12171 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12172
12173 if(get_bit(deprecated_rules, 12) != 0)
12174 custom_subscreen[0].objects[i].d3=1;
12175 else
12176 custom_subscreen[0].objects[i].d3=0;
12177
12178 break;
12179 }
12180
12181 default:
12182 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12183 break;
12184 }
12185 }
12186
12187 custom_subscreen[0].ss_type=sstACTIVE;
12188 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12189 tempsub = z3_active_ab;
12190
12191 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12192 {
12193 switch(tempsub[i].type)
12194 {
12195 case ssoTEXT:
12196 case ssoTEXTBOX:
12197 case ssoCURRENTITEMTEXT:
12198 case ssoCURRENTITEMCLASSTEXT:
12199 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12200
12201 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12202 custom_subscreen[1].objects[i].dp1 = NULL;
12203 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12204 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12205 break;
12206
12207 case ssoLIFEMETER:
12208 {
12209 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12210
12211 if(get_bit(deprecated_rules, 12) != 0)
12212 custom_subscreen[1].objects[i].d3=1;
12213 else
12214 custom_subscreen[1].objects[i].d3=0;
12215
12216 break;
12217 }
12218
12219 default:
12220 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12221 break;
12222 }
12223 }
12224
12225 custom_subscreen[1].ss_type=sstACTIVE;
12226 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12227 tempsub = z3_passive_a;
12228
12229 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12230 {
12231 switch(tempsub[i].type)
12232 {
12233 case ssoTEXT:
12234 case ssoTEXTBOX:
12235 case ssoCURRENTITEMTEXT:
12236 case ssoCURRENTITEMCLASSTEXT:
12237 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12238
12239 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12240 custom_subscreen[2].objects[i].dp1 = NULL;
12241 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12242 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12243 break;
12244
12245 case ssoLIFEMETER:
12246 {
12247 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12248
12249 if(get_bit(deprecated_rules, 12) != 0)
12250 custom_subscreen[2].objects[i].d3=1;
12251 else
12252 custom_subscreen[2].objects[i].d3=0;
12253
12254 break;
12255 }
12256
12257 default:
12258 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12259 break;
12260 }
12261 }
12262
12263 custom_subscreen[2].ss_type=sstPASSIVE;
12264 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12265 tempsub = z3_passive_ab;
12266
12267 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12268 {
12269 switch(tempsub[i].type)
12270 {
12271 case ssoTEXT:
12272 case ssoTEXTBOX:
12273 case ssoCURRENTITEMTEXT:
12274 case ssoCURRENTITEMCLASSTEXT:
12275 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12276
12277 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12278 custom_subscreen[3].objects[i].dp1 = NULL;
12279 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12280 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12281 break;
12282
12283 case ssoLIFEMETER:
12284 {
12285 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12286
12287 if(get_bit(deprecated_rules, 12) != 0)
12288 custom_subscreen[3].objects[i].d3=1;
12289 else
12290 custom_subscreen[3].objects[i].d3=0;
12291
12292 break;
12293 }
12294
12295 default:
12296 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12297 break;
12298 }
12299 }
12300
12301 custom_subscreen[3].ss_type=sstPASSIVE;
12302 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12303 break;
12304 }
12305 }
12306
12307
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; ++i)
12308 {
12309 48 purge_blank_subscreen_objects(&custom_subscreen[i]);
12310 48 }
12311
12312 12 return 0;
12313 }
12314
12315 extern script_data *ffscripts[NUMSCRIPTFFC];
12316 extern script_data *itemscripts[NUMSCRIPTITEM];
12317 extern script_data *guyscripts[NUMSCRIPTGUYS];
12318 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12319 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12320 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12321 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12322 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12323 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12324 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12325 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12326 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12327 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12328 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12329
12330
12331
12332 25 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12333 {
12334 int32_t dummy;
12335 25 word s_version=0, s_cversion=0, zmeta_version=0;
12336 25 byte numscripts=0;
12337 25 numscripts=numscripts; //to avoid unused variables warnings
12338 int32_t ret;
12339
12340 //section version info
12341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&s_version,f,true))
12342 {
12343 return qe_invalid;
12344 }
12345
12346 25 FFCore.quest_format[vFFScript] = s_version;
12347
12348
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
12349 {
12350 return qe_invalid;
12351 }
12352
12353
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version >= 18)
12354 {
12355
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&zmeta_version,f,true))
12356 {
12357 return qe_invalid;
12358 }
12359 1 }
12360
12361 //al_trace("Scripts version %d\n", s_version);
12362 //section size
12363
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
12364 {
12365 return qe_invalid;
12366 }
12367
12368 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12369 25 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12370 25 temp_ffscript_version = s_version;
12371 //miscQdata *the_misc;
12372
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12373 25 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12374
12375 //finally... section data
12376
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12377 {
12378 12800 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12379
12380
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(ret != 0) return qe_invalid;
12381 12800 }
12382
12383 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12384 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12385 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12386 * there was a version bump a week before a change that broke stuff.
12387 */
12388
6/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 24 times.
25 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12389 {
12390 24 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12391 24 }
12392
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
25 if(s_version < 19 && keepdata)
12393 {
12394 24 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12395 24 }
12396
12397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version > 1)
12398 {
12399
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12400 {
12401 6400 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12402
12403
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(ret != 0) return qe_invalid;
12404 6400 }
12405
12406
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12407 {
12408 6400 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12409
12410
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(ret != 0) return qe_invalid;
12411 6400 }
12412
12413
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12414 {
12415 6400 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12416
12417
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(ret != 0) return qe_invalid;
12418 6400 }
12419
12420
12421
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12422 {
12423 6400 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12424
12425
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(ret != 0) return qe_invalid;
12426 6400 }
12427
12428
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 16)
12429 {
12430
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12431 {
12432 8 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12433
12434
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(ret != 0) return qe_invalid;
12435 8 }
12436 1 }
12437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 else if(s_version > 13)
12438 {
12439 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12440 {
12441 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12442
12443 if(ret != 0) return qe_invalid;
12444 }
12445
12446 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12447 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12448
12449 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12450 }
12451
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 else if(s_version > 4)
12452 {
12453
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12454 {
12455 96 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12456
12457
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(ret != 0) return qe_invalid;
12458 96 }
12459
12460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12461
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12462
12463
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12464
12465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12466
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12467
12468
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12469
12470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12471
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 delete globalscripts[GLOBAL_SCRIPT_F6];
12472
12473
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12474
12475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12476
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12477
12478
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12479 24 }
12480 else
12481 {
12482 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12483 {
12484 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12485
12486 if(ret != 0) return qe_invalid;
12487 }
12488
12489 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12490 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12491
12492 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12493
12494 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12495 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12496
12497 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12498
12499 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12500 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12501
12502 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12503
12504 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12505 delete globalscripts[GLOBAL_SCRIPT_F6];
12506
12507 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12508
12509 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12510 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12511
12512 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12513 }
12514
12515
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 10) //expanded the number of Player scripts to 5.
12516 {
12517
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12518 {
12519 5 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12520
12521
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(ret != 0) return qe_invalid;
12522 5 }
12523 1 }
12524 else
12525 {
12526
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 24 times.
96 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12527 {
12528 72 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12529
12530
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(ret != 0) return qe_invalid;
12531 72 }
12532
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(playerscripts[3] != NULL)
12533
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 delete playerscripts[3];
12534
12535
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 playerscripts[3] = new script_data();
12536
12537
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(playerscripts[4] != NULL)
12538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 delete playerscripts[4];
12539
12540
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 playerscripts[4] = new script_data();
12541 }
12542
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
25 if(s_version > 8 && s_version < 10)
12543 {
12544
12545 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12546 {
12547 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12548
12549 if(ret != 0) return qe_invalid;
12550 }
12551 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12552 {
12553 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12554
12555 if(ret != 0) return qe_invalid;
12556 }
12557
12558 }
12559
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version >= 10)
12560 {
12561
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12562 {
12563 256 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12564
12565
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(ret != 0) return qe_invalid;
12566 256 }
12567
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12568 {
12569 256 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12570
12571
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(ret != 0) return qe_invalid;
12572 256 }
12573
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12574 {
12575 256 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12576
12577
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(ret != 0) return qe_invalid;
12578 256 }
12579
12580 1 }
12581
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version >=12)
12582 {
12583
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12584 {
12585 256 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12586
12587
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(ret != 0) return qe_invalid;
12588 256 }
12589 1 }
12590
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version >=15)
12591 {
12592
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
513 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12593 {
12594 512 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12595
12596
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(ret != 0) return qe_invalid;
12597 512 }
12598 1 }
12599
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version >19)
12600 {
12601 1 word numgenscripts = NUMSCRIPTSGENERIC;
12602
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&numgenscripts,f,true))
12603 {
12604 return qe_invalid;
12605 }
12606
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
513 for(int32_t i = 0; i < numgenscripts; i++)
12607 {
12608 512 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12609
12610
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(ret != 0) return qe_invalid;
12611 512 }
12612 1 }
12613
12614 /*
12615 else //Is this trip really necessary?
12616 {
12617 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12618 {
12619
12620 ewpnscripts[i] = NULL;
12621 }
12622 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12623 {
12624 dmapscripts[i] = NULL;
12625 }
12626 }
12627 */
12628
12629 25 }
12630
12631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version > 2)
12632 {
12633 int32_t bufsize;
12634 25 p_igetl(&bufsize, f, true);
12635 25 char * buf = new char[bufsize+1];
12636 25 pfread(buf, bufsize, f, true);
12637 25 buf[bufsize]=0;
12638
12639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
12640 25 zScript = string(buf);
12641
12642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 delete[] buf;
12643 word numffcbindings;
12644 25 p_igetw(&numffcbindings, f, true);
12645
12646
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 25 times.
175 for(int32_t i=0; i<numffcbindings; i++)
12647 {
12648 word id;
12649 150 p_igetw(&id, f, true);
12650 150 p_igetl(&bufsize, f, true);
12651 150 buf = new char[bufsize+1];
12652 150 pfread(buf, bufsize, f, true);
12653 150 buf[bufsize]=0;
12654
12655 //fix for buggy older saved quests -DD
12656
2/4
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 150 times.
150 if(keepdata && id < NUMSCRIPTFFC-1)
12657 150 ffcmap[id].scriptname = buf;
12658
12659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 delete[] buf;
12660 150 }
12661
12662 word numglobalbindings;
12663 25 p_igetw(&numglobalbindings, f, true);
12664
12665
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 25 times.
133 for(int32_t i=0; i<numglobalbindings; i++)
12666 {
12667 word id;
12668 108 p_igetw(&id, f, true);
12669 108 p_igetl(&bufsize, f, true);
12670 108 buf = new char[bufsize+1];
12671 108 pfread(buf, bufsize, f, true);
12672 108 buf[bufsize]=0;
12673
12674 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12675 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12676 // Ignore these. -DD
12677
4/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 64 times.
108 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12678 {
12679 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12680
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(strcmp(buf,"~Continue") == 0)
12681 {
12682 globalmap[id].scriptname = "";
12683
12684 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12685 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12686 }
12687 else
12688 {
12689 64 globalmap[id].scriptname = buf;
12690 }
12691 64 }
12692
12693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 delete[] buf;
12694 108 }
12695
12696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version > 3)
12697 {
12698 word numitembindings;
12699 25 p_igetw(&numitembindings, f, true);
12700
12701
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 25 times.
28 for(int32_t i=0; i<numitembindings; i++)
12702 {
12703 word id;
12704 3 p_igetw(&id, f, true);
12705 3 p_igetl(&bufsize, f, true);
12706 3 buf = new char[bufsize+1];
12707 3 pfread(buf, bufsize, f, true);
12708 3 buf[bufsize]=0;
12709
12710 //fix this too
12711
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if(keepdata && id <NUMSCRIPTITEM-1)
12712 3 itemmap[id].scriptname = buf;
12713
12714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 delete[] buf;
12715 3 }
12716 25 }
12717 //(v9+)
12718
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version > 8)
12719 {
12720 //npc scripts
12721 word numnpcbindings;
12722 1 p_igetw(&numnpcbindings, f, true);
12723
12724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<numnpcbindings; i++)
12725 {
12726 word id;
12727 p_igetw(&id, f, true);
12728 p_igetl(&bufsize, f, true);
12729 buf = new char[bufsize+1];
12730 pfread(buf, bufsize, f, true);
12731 buf[bufsize]=0;
12732
12733 //fix this too
12734 if(keepdata && id <NUMSCRIPTGUYS-1)
12735 npcmap[id].scriptname = buf;
12736
12737 delete[] buf;
12738 }
12739 //lweapon
12740 word numlwpnbindings;
12741 1 p_igetw(&numlwpnbindings, f, true);
12742
12743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<numlwpnbindings; i++)
12744 {
12745 word id;
12746 p_igetw(&id, f, true);
12747 p_igetl(&bufsize, f, true);
12748 buf = new char[bufsize+1];
12749 pfread(buf, bufsize, f, true);
12750 buf[bufsize]=0;
12751
12752 //fix this too
12753 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12754 lwpnmap[id].scriptname = buf;
12755
12756 delete[] buf;
12757 }
12758 //eweapon
12759 word numewpnbindings;
12760 1 p_igetw(&numewpnbindings, f, true);
12761
12762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<numewpnbindings; i++)
12763 {
12764 word id;
12765 p_igetw(&id, f, true);
12766 p_igetl(&bufsize, f, true);
12767 buf = new char[bufsize+1];
12768 pfread(buf, bufsize, f, true);
12769 buf[bufsize]=0;
12770
12771 //fix this too
12772 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12773 ewpnmap[id].scriptname = buf;
12774
12775 delete[] buf;
12776 }
12777 //hero
12778 word numherobindings;
12779 1 p_igetw(&numherobindings, f, true);
12780
12781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<numherobindings; i++)
12782 {
12783 word id;
12784 p_igetw(&id, f, true);
12785 p_igetl(&bufsize, f, true);
12786 buf = new char[bufsize+1];
12787 pfread(buf, bufsize, f, true);
12788 buf[bufsize]=0;
12789
12790 //fix this too
12791 if(keepdata && id <NUMSCRIPTPLAYER-1)
12792 playermap[id].scriptname = buf;
12793
12794 delete[] buf;
12795 }
12796 //dmaps
12797 word numdmapbindings;
12798 1 p_igetw(&numdmapbindings, f, true);
12799
12800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<numdmapbindings; i++)
12801 {
12802 word id;
12803 p_igetw(&id, f, true);
12804 p_igetl(&bufsize, f, true);
12805 buf = new char[bufsize+1];
12806 pfread(buf, bufsize, f, true);
12807 buf[bufsize]=0;
12808
12809 //fix this too
12810 if(keepdata && id <NUMSCRIPTSDMAP-1)
12811 dmapmap[id].scriptname = buf;
12812
12813 delete[] buf;
12814 }
12815 //screen
12816 word numscreenbindings;
12817 1 p_igetw(&numscreenbindings, f, true);
12818
12819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<numscreenbindings; i++)
12820 {
12821 word id;
12822 p_igetw(&id, f, true);
12823 p_igetl(&bufsize, f, true);
12824 buf = new char[bufsize+1];
12825 pfread(buf, bufsize, f, true);
12826 buf[bufsize]=0;
12827
12828 //fix this too
12829 if(keepdata && id <NUMSCRIPTSDMAP-1)
12830 screenmap[id].scriptname = buf;
12831
12832 delete[] buf;
12833 }
12834 1 }
12835
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version > 11)
12836 {
12837 word numspritebindings;
12838 1 p_igetw(&numspritebindings, f, true);
12839
12840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<numspritebindings; i++)
12841 {
12842 word id;
12843 p_igetw(&id, f, true);
12844 p_igetl(&bufsize, f, true);
12845 buf = new char[bufsize+1];
12846 pfread(buf, bufsize, f, true);
12847 buf[bufsize]=0;
12848
12849 //fix this too
12850 if(keepdata && id <NUMSCRIPTSDMAP-1)
12851 itemspritemap[id].scriptname = buf;
12852
12853 delete[] buf;
12854 }
12855 1 }
12856
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version >= 15)
12857 {
12858 word numcombobindings;
12859 1 p_igetw(&numcombobindings, f, true);
12860
12861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<numcombobindings; i++)
12862 {
12863 word id;
12864 p_igetw(&id, f, true);
12865 p_igetl(&bufsize, f, true);
12866 buf = new char[bufsize+1];
12867 pfread(buf, bufsize, f, true);
12868 buf[bufsize]=0;
12869
12870 //fix this too
12871 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
12872 comboscriptmap[id].scriptname = buf;
12873
12874 delete[] buf;
12875 }
12876 1 }
12877
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(s_version > 19)
12878 {
12879 word numgenericbindings;
12880 1 p_igetw(&numgenericbindings, f, true);
12881
12882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<numgenericbindings; i++)
12883 {
12884 word id;
12885 p_igetw(&id, f, true);
12886 p_igetl(&bufsize, f, true);
12887 buf = new char[bufsize+1];
12888 pfread(buf, bufsize, f, true);
12889 buf[bufsize]=0;
12890
12891 //fix this too
12892 if(keepdata && id <NUMSCRIPTSGENERIC-1)
12893 genericmap[id].scriptname = buf;
12894
12895 delete[] buf;
12896 }
12897 1 }
12898 25 }
12899
12900 25 return 0;
12901 25 }
12902
12903 25 void reset_scripts()
12904 {
12905 //OK, who spaced this? ;)
12906
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12907 {
12908
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12800 times.
12800 if(ffscripts[i]!=NULL) delete ffscripts[i];
12909 12800 }
12910
12911
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12912 {
12913
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(itemscripts[i]!=NULL) delete itemscripts[i];
12914 6400 }
12915
12916
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12917 {
12918
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(guyscripts[i]!=NULL) delete guyscripts[i];
12919 6400 }
12920
12921
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12922 {
12923
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
12924 6400 }
12925
12926
12927
12928
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12929 {
12930
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(screenscripts[i]!=NULL) delete screenscripts[i];
12931 6400 }
12932
12933
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 25 times.
225 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12934 {
12935
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 200 times.
200 if(globalscripts[i]!=NULL) delete globalscripts[i];
12936 200 }
12937
12938
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 25 times.
150 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12939 {
12940
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(playerscripts[i]!=NULL) delete playerscripts[i];
12941 125 }
12942
12943
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12944 {
12945
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
12946 6400 }
12947
12948
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12949 {
12950
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
12951 6400 }
12952
12953
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12954 {
12955
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
12956 6400 }
12957
12958
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12959 {
12960
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
12961 6400 }
12962
12963
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12964 {
12965
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12800 times.
12800 if(comboscripts[i]!=NULL) delete comboscripts[i];
12966 12800 }
12967
12968
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12969 {
12970
3/4
✓ Branch 0 taken 5120 times.
✓ Branch 1 taken 7680 times.
✓ Branch 2 taken 7680 times.
✗ Branch 3 not taken.
12800 if(genericscripts[i]!=NULL) delete genericscripts[i];
12971
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 genericscripts[i] = new script_data();
12972 12800 }
12973
12974
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12975 {
12976
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 ffscripts[i] = new script_data();
12977 12800 }
12978
12979
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12980 {
12981
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 itemscripts[i] = new script_data();
12982 6400 }
12983
12984
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12985 {
12986
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 guyscripts[i] = new script_data();
12987 6400 }
12988
12989
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12990 {
12991
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 wpnscripts[i] = new script_data();
12992 6400 }
12993
12994
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12995 {
12996
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 screenscripts[i] = new script_data();
12997 6400 }
12998
12999
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 25 times.
225 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13000 {
13001
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[i] = new script_data();
13002 200 }
13003
13004
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 25 times.
150 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13005 {
13006
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 playerscripts[i] = new script_data();
13007 125 }
13008
13009
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13010 {
13011
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 lwpnscripts[i] = new script_data();
13012 6400 }
13013
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13014 {
13015
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 ewpnscripts[i] = new script_data();
13016 6400 }
13017
13018
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13019 {
13020
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 dmapscripts[i] = new script_data();
13021 6400 }
13022
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13023 {
13024
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 itemspritescripts[i] = new script_data();
13025 6400 }
13026
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13027 {
13028
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 comboscripts[i] = new script_data();
13029 12800 }
13030 25 }
13031
13032 extern script_command command_list[];
13033 40629 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13034 {
13035 //Please also update loadquest() when modifying this method -DD
13036 40629 char b33[34] = {0};
13037 40629 b33[33] = 0;
13038 40629 ffscript temp_script;
13039 40629 int32_t num_commands=1000;
13040
13041
1/2
✓ Branch 0 taken 40629 times.
✗ Branch 1 not taken.
40629 if(s_version>=2)
13042 {
13043
2/4
✓ Branch 0 taken 40629 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40629 times.
✗ Branch 3 not taken.
40629 if(!p_igetl(&num_commands,f,true))
13044 {
13045 return qe_invalid;
13046 }
13047 40629 }
13048
13049
1/2
✓ Branch 0 taken 40629 times.
✗ Branch 1 not taken.
40629 if(keepdata)
13050 {
13051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40629 times.
40629 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40629 times.
40629 delete (*script);
13053
2/4
✓ Branch 0 taken 40629 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40629 times.
✗ Branch 3 not taken.
40629 (*script) = new script_data(num_commands);
13054 40629 }
13055
2/2
✓ Branch 0 taken 3597 times.
✓ Branch 1 taken 37032 times.
40629 if(s_version >= 16)
13056 {
13057
1/2
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
3597 zasm_meta temp_meta;
13058
13059
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13060 {
13061 return qe_invalid;
13062 }
13063
13064
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_igetw(&(temp_meta.meta_v),f,true))
13065 {
13066 return qe_invalid;
13067 }
13068
13069
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13070 {
13071 return qe_invalid;
13072 }
13073
13074
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_getc(&(temp_meta.script_type),f,true))
13075 {
13076 return qe_invalid;
13077 }
13078
13079
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 3597 times.
32373 for(int32_t q = 0; q < 8; ++q)
13080 {
13081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28776 times.
28776 if(zmeta_version < 3)
13082 {
13083 for(int32_t c = 0; c < 33; ++c)
13084 {
13085 if(!p_getc(&(b33[c]),f,true))
13086 {
13087 return qe_invalid;
13088 }
13089 }
13090 temp_meta.run_idens[q].assign(b33);
13091 }
13092 else
13093 {
13094
2/4
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28776 times.
✗ Branch 3 not taken.
28776 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13095 {
13096 return qe_invalid;
13097 }
13098 }
13099 28776 }
13100
13101
2/2
✓ Branch 0 taken 3597 times.
✓ Branch 1 taken 28776 times.
32373 for(int32_t q = 0; q < 8; ++q)
13102 {
13103
2/4
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28776 times.
✗ Branch 3 not taken.
28776 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13104 {
13105 return qe_invalid;
13106 }
13107 28776 }
13108
13109
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_getc(&(temp_meta.flags),f,true))
13110 {
13111 return qe_invalid;
13112 }
13113
13114
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13115 {
13116 return qe_invalid;
13117 }
13118
13119
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13120 {
13121 return qe_invalid;
13122 }
13123
13124
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13125 {
13126 return qe_invalid;
13127 }
13128
13129
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13130 {
13131 return qe_invalid;
13132 }
13133
13134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3597 times.
3597 if(zmeta_version == 2)
13135 {
13136 for(int32_t c = 0; c < 33; ++c)
13137 {
13138 if(!p_getc(&b33[c],f,true))
13139 {
13140 return qe_invalid;
13141 }
13142 }
13143 temp_meta.script_name.assign(b33);
13144
13145 for(int32_t c = 0; c < 33; ++c)
13146 {
13147 if(!p_getc(&b33[c],f,true))
13148 {
13149 return qe_invalid;
13150 }
13151 }
13152 temp_meta.author.assign(b33);
13153 }
13154
1/2
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
3597 else if(zmeta_version > 2)
13155 {
13156
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_getcstr(&temp_meta.script_name,f,true))
13157 return qe_invalid;
13158
2/4
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3597 times.
✗ Branch 3 not taken.
3597 if(!p_getcstr(&temp_meta.author,f,true))
13159 return qe_invalid;
13160 3597 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13161
2/2
✓ Branch 0 taken 35970 times.
✓ Branch 1 taken 3597 times.
39567 for(auto q = 0; q < num_meta_attrib; ++q)
13162 {
13163
2/4
✓ Branch 0 taken 35970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35970 times.
✗ Branch 3 not taken.
35970 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13164 return qe_invalid;
13165
2/4
✓ Branch 0 taken 35970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35970 times.
✗ Branch 3 not taken.
35970 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13166 return qe_invalid;
13167 35970 }
13168
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 3597 times.
32373 for(auto q = 0; q < 8; ++q)
13169 {
13170
2/4
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28776 times.
✗ Branch 3 not taken.
28776 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13171 return qe_invalid;
13172
2/4
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28776 times.
✗ Branch 3 not taken.
28776 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13173 return qe_invalid;
13174 28776 }
13175
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 3597 times.
32373 for(auto q = 0; q < 8; ++q)
13176 {
13177
2/4
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28776 times.
✗ Branch 3 not taken.
28776 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13178 return qe_invalid;
13179
2/4
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28776 times.
✗ Branch 3 not taken.
28776 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13180 return qe_invalid;
13181 28776 }
13182
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 3597 times.
61149 for(auto q = 0; q < 16; ++q)
13183 {
13184
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13185 return qe_invalid;
13186
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13187 return qe_invalid;
13188 57552 }
13189 3597 }
13190
1/2
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
3597 if(zmeta_version > 3)
13191 {
13192
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 3597 times.
32373 for(auto q = 0; q < 8; ++q)
13193 {
13194
2/4
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28776 times.
✗ Branch 3 not taken.
28776 if(!p_getcstr(&temp_meta.initd[q],f,true))
13195 return qe_invalid;
13196
2/4
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28776 times.
✗ Branch 3 not taken.
28776 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13197 return qe_invalid;
13198 28776 }
13199
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 3597 times.
32373 for(auto q = 0; q < 8; ++q)
13200 {
13201
2/4
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28776 times.
✗ Branch 3 not taken.
28776 if(!p_getc(&temp_meta.initd_type[q],f,true))
13202 return qe_invalid;
13203 28776 }
13204 3597 }
13205 else
13206 {
13207 for(auto q = 0; q < 8; ++q)
13208 {
13209 temp_meta.initd[q] = temp_meta.run_idens[q];
13210 }
13211 }
13212
13213
1/2
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
3597 if(keepdata)
13214
1/2
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
3597 (*script)->meta = temp_meta;
13215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3597 times.
3597 }
13216
13217
1/2
✓ Branch 0 taken 40629 times.
✗ Branch 1 not taken.
40629 temp_script.clear();
13218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 711000 times.
711000 for(int32_t j=0; j<num_commands; j++)
13219 {
13220
2/4
✓ Branch 0 taken 711000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 711000 times.
✗ Branch 3 not taken.
711000 if(!p_igetw(&(temp_script.command),f,true))
13221 {
13222 return qe_invalid;
13223 }
13224
13225
2/2
✓ Branch 0 taken 670371 times.
✓ Branch 1 taken 40629 times.
711000 if(temp_script.command == 0xFFFF)
13226 {
13227
1/2
✓ Branch 0 taken 40629 times.
✗ Branch 1 not taken.
40629 if(keepdata)
13228
1/2
✓ Branch 0 taken 40629 times.
✗ Branch 1 not taken.
40629 (*script)->zasm[j].clear();
13229 40629 break;
13230 }
13231 else
13232 {
13233
2/4
✓ Branch 0 taken 670371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 670371 times.
✗ Branch 3 not taken.
670371 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13234 {
13235 return qe_invalid;
13236 }
13237
13238
2/4
✓ Branch 0 taken 670371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 670371 times.
✗ Branch 3 not taken.
670371 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13239 {
13240 return qe_invalid;
13241 }
13242
13243
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 670269 times.
670371 if(s_version >= 21)
13244 {
13245 102 uint32_t sz = 0;
13246
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetl(&sz,f,keepdata))
13247 {
13248 return qe_invalid;
13249 }
13250
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 101 times.
102 if(sz) //string found
13251 {
13252
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 temp_script.strptr = new std::string();
13253 char dummy;
13254
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(size_t q = 0; q < sz; ++q)
13255 {
13256
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&dummy,f,keepdata))
13257 {
13258 return qe_invalid;
13259 }
13260
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_script.strptr->push_back(dummy);
13261 4 }
13262 1 }
13263
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetl(&sz,f,keepdata))
13264 {
13265 return qe_invalid;
13266 }
13267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(sz) //vector found
13268 {
13269 temp_script.vecptr = new std::vector<int32_t>();
13270 int32_t dummy;
13271 for(size_t q = 0; q < sz; ++q)
13272 {
13273 if(!p_igetl(&dummy,f,keepdata))
13274 {
13275 return qe_invalid;
13276 }
13277 temp_script.vecptr->push_back(dummy);
13278 }
13279 }
13280 102 }
13281
13282
1/2
✓ Branch 0 taken 670371 times.
✗ Branch 1 not taken.
670371 if(keepdata)
13283 {
13284
1/2
✓ Branch 0 taken 670371 times.
✗ Branch 1 not taken.
670371 temp_script.give((*script)->zasm[j]);
13285 670371 }
13286 }
13287
1/2
✓ Branch 0 taken 670371 times.
✗ Branch 1 not taken.
670371 temp_script.clear();
13288 670371 }
13289
13290 40629 return 0;
13291 40629 }
13292
13293 extern SAMPLE customsfxdata[WAV_COUNT];
13294 extern uint8_t customsfxflag[WAV_COUNT>>3];
13295 extern int32_t sfxdat;
13296 extern DATAFILE *sfxdata;
13297 const char *old_sfx_string[Z35] =
13298 {
13299 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13300 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13301 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13302 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13303 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13304 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13305 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13306 "Din's Fire", "Enemy falls from ceiling", "Farore's Wind", "Fireball", "Tall Grass slashed",
13307 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13308 "Nayru's Love shield", "Nayru's Love shield 2", "Push block", "Rock", "Spell rocket down",
13309 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13310 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13311 };
13312 char *sfx_string[WAV_COUNT];
13313
13314 25 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13315 {
13316 //these are here to bypass compiler warnings about unused arguments
13317 25 Header=Header;
13318
13319 int32_t dummy;
13320 25 word s_version=0, s_cversion=0;
13321 //int32_t ret;
13322 SAMPLE temp_sample;
13323 25 temp_sample.loop_start=0;
13324 25 temp_sample.loop_end=0;
13325 25 temp_sample.param=0;
13326
13327 //section version info
13328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&s_version,f,true))
13329 {
13330 return qe_invalid;
13331 }
13332
13333 25 FFCore.quest_format[vSFX] = s_version;
13334
13335 //al_trace("SFX version %d\n", s_version);
13336
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
13337 {
13338 return qe_invalid;
13339 }
13340
13341 //section size
13342
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
13343 {
13344 return qe_invalid;
13345 }
13346
13347 /* HIGHLY UNORTHODOX UPDATING THING, by L
13348 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13349 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13350 * changing from 1 to 2.
13351 */
13352
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if(s_version < 2 && keepdata)
13353 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13354
13355 /* End highly unorthodox updating thing */
13356
13357 25 int32_t wavcount = WAV_COUNT;
13358
13359
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version < 6)
13360 wavcount = 128;
13361
13362 uint8_t tempflag[WAV_COUNT>>3];
13363
13364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version < 4)
13365 {
13366 memset(tempflag, 0xFF, WAV_COUNT>>3);
13367 }
13368 else
13369 {
13370
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version < 6)
13371 memset(tempflag, 0, WAV_COUNT>>3);
13372
13373
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 25 times.
825 for(int32_t i=0; i<(wavcount>>3); i++)
13374 {
13375 800 p_getc(&tempflag[i], f, true);
13376 800 }
13377
13378 }
13379
13380
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version>4)
13381 {
13382
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=1; i<WAV_COUNT; i++)
13383 {
13384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6375 times.
6375 if(keepdata)
13385 {
13386 6375 sprintf(sfx_string[i],"s%03d",i);
13387
13388
2/2
✓ Branch 0 taken 4875 times.
✓ Branch 1 taken 1500 times.
6375 if((i<Z35))
13389 1500 strcpy(sfx_string[i], old_sfx_string[i-1]);
13390 6375 }
13391
13392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6375 times.
6375 if(i>=wavcount)
13393 continue;
13394
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 6290 times.
6375 if(get_bit(tempflag, i-1))
13395 {
13396 char tempname[36];
13397
13398
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!pfread(tempname, 36, f, keepdata))
13399 {
13400 return qe_invalid;
13401 }
13402
13403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if(keepdata)
13404 {
13405 85 strcpy(sfx_string[i], tempname);
13406 85 sfx_string[i][35] = 0; //Force NULL Termination
13407 85 }
13408 85 }
13409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6290 times.
6290 else if(keepdata)
13410 {
13411 6290 sprintf(sfx_string[i],"s%03d",i);
13412
13413
2/2
✓ Branch 0 taken 4853 times.
✓ Branch 1 taken 1437 times.
6290 if(i<Z35)
13414 1437 strcpy(sfx_string[i], old_sfx_string[i-1]);
13415 6290 sfx_string[i][35] = 0; //Force NULL Termination
13416 6290 }
13417 6375 }
13418 25 }
13419 else
13420 {
13421 if(keepdata)
13422 {
13423 for(int32_t i=1; i<WAV_COUNT; i++)
13424 {
13425 sprintf(sfx_string[i],"s%03d",i);
13426
13427 if(i<Z35)
13428 strcpy(sfx_string[i], old_sfx_string[i-1]);
13429 }
13430 }
13431 }
13432
13433 //finally... section data
13434
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=1; i<wavcount; i++)
13435 {
13436
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 6290 times.
6375 if(get_bit(tempflag, i-1))
13437 {
13438
13439
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetl(&dummy,f,true))
13440 {
13441 return qe_invalid;
13442 }
13443
13444 85 (temp_sample.bits) = dummy;
13445
13446
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetl(&dummy,f,true))
13447 {
13448 return qe_invalid;
13449 }
13450
13451 85 (temp_sample.stereo) = dummy;
13452
13453
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetl(&dummy,f,keepdata))
13454 {
13455 return qe_invalid;
13456 }
13457
13458 85 (temp_sample.freq) = dummy;
13459
13460
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetl(&dummy,f,keepdata))
13461 {
13462 return qe_invalid;
13463 }
13464
13465 85 (temp_sample.priority) = dummy;
13466
13467
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetl(&(temp_sample.len),f,true))
13468 {
13469 return qe_invalid;
13470 }
13471
13472
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13473 {
13474 return qe_invalid;
13475 }
13476
13477
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13478 {
13479 return qe_invalid;
13480 }
13481
13482
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetl(&(temp_sample.param),f,keepdata))
13483 {
13484 return qe_invalid;
13485 }
13486
13487 // al_trace("F%i: L%i\n",i,temp_sample.len);
13488 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13489 85 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13490 85 temp_sample.data = calloc(len,1);
13491
13492
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(s_version < 3)
13493 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13494
13495 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if(s_version < 2)
13497 {
13498 if(!pfread(temp_sample.data, len,f,keepdata))
13499 {
13500 return qe_invalid;
13501 }
13502 }
13503 else
13504 {
13505 //re-endianfy the data
13506 85 int32_t wordstoread = len / sizeof(word);
13507
13508
2/2
✓ Branch 0 taken 2007251 times.
✓ Branch 1 taken 85 times.
2007336 for(int32_t j=0; j<wordstoread; j++)
13509 {
13510 word temp;
13511
13512
1/2
✓ Branch 0 taken 2007251 times.
✗ Branch 1 not taken.
2007251 if(!p_igetw(&temp, f, keepdata))
13513 {
13514 return qe_invalid;
13515 }
13516
13517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2007251 times.
2007251 if(keepdata)
13518 2007251 ((word *)temp_sample.data)[j] = temp;
13519 2007251 }
13520 }
13521 85 }
13522
2/2
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 4853 times.
6290 else if(i < Z35)
13523 {
13524 1437 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13525 1437 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13526 1437 set_bit(tempflag, i-1, 1);
13527 1437 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13528 1437 temp_sample.data = calloc(len,1);
13529 1437 memcpy(temp_sample.data, datsamp->data, len);
13530 1437 }
13531 4853 else continue;
13532
13533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1522 times.
1522 if(keepdata)
13534 {
13535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1522 times.
1522 if(customsfxdata[i].data!=NULL)
13536 {
13537 // delete [] customsfxdata[i].data;
13538 1522 free(customsfxdata[i].data);
13539 1522 }
13540
13541 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13542 1522 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13543 1522 customsfxdata[i].data = calloc(len2,1);
13544 1522 customsfxdata[i].bits = temp_sample.bits;
13545 1522 customsfxdata[i].stereo = temp_sample.stereo;
13546 1522 customsfxdata[i].freq = temp_sample.freq;
13547 1522 customsfxdata[i].priority = temp_sample.priority;
13548 1522 customsfxdata[i].len = temp_sample.len;
13549 1522 customsfxdata[i].loop_start = temp_sample.loop_start;
13550 1522 customsfxdata[i].loop_end = temp_sample.loop_end;
13551 1522 customsfxdata[i].param = temp_sample.param;
13552 1522 int32_t cpylen = len2;
13553
13554
1/2
✓ Branch 0 taken 1522 times.
✗ Branch 1 not taken.
1522 if(s_version<3)
13555 {
13556 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13557 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13558 }
13559
13560 1522 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13561 1522 }
13562
13563 1522 free(temp_sample.data);
13564 1522 }
13565
13566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
13567 25 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13568
13569 25 sfxdat=0;
13570 25 return 0;
13571 25 }
13572
13573 25 void setupsfx()
13574 {
13575
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=1; i<WAV_COUNT; i++)
13576 {
13577 6375 sprintf(sfx_string[i],"s%03d",i);
13578
13579
2/2
✓ Branch 0 taken 4875 times.
✓ Branch 1 taken 1500 times.
6375 if(i<Z35)
13580 {
13581 1500 strcpy(sfx_string[i], old_sfx_string[i-1]);
13582 1500 }
13583
13584 6375 memset(customsfxflag, 0, WAV_COUNT>>3);
13585
13586 6375 int32_t j=i;
13587
13588
2/2
✓ Branch 0 taken 1525 times.
✓ Branch 1 taken 4850 times.
6375 if(i>Z35)
13589 {
13590 4850 i=Z35;
13591 4850 }
13592
13593 6375 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13594
13595
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 3825 times.
6375 if(customsfxdata[j].data!=NULL)
13596 {
13597 // delete [] customsfxdata[j].data;
13598 3825 free(customsfxdata[j].data);
13599 3825 }
13600
13601 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13602 6375 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13603 6375 customsfxdata[j].bits = temp_sample->bits;
13604 6375 customsfxdata[j].stereo = temp_sample->stereo;
13605 6375 customsfxdata[j].freq = temp_sample->freq;
13606 6375 customsfxdata[j].priority = temp_sample->priority;
13607 6375 customsfxdata[j].len = temp_sample->len;
13608 6375 customsfxdata[j].loop_start = temp_sample->loop_start;
13609 6375 customsfxdata[j].loop_end = temp_sample->loop_end;
13610 6375 customsfxdata[j].param = temp_sample->param;
13611 6375 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13612 6375 i=j;
13613 6375 }
13614 25 }
13615
13616 extern char *guy_string[eMAXGUYS];
13617 extern const char *old_guy_string[OLDMAXGUYS];
13618
13619 25 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13620 {
13621 dword dummy;
13622 word guy_cversion;
13623 25 word guyversion=0;
13624
13625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version >= 0x193)
13626 {
13627 //section version info
13628
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&guyversion,f,true))
13629 {
13630 return qe_invalid;
13631 }
13632
13633 25 FFCore.quest_format[vGuys] = guyversion;
13634
13635 //al_trace("Guys version %d\n", guyversion);
13636
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&guy_cversion,f,true))
13637 {
13638 return qe_invalid;
13639 }
13640 25 al_trace("Guy CVersion is: %d\n", guy_cversion);
13641 //section size
13642
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
13643 {
13644 return qe_invalid;
13645 }
13646 25 }
13647
13648
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(guyversion > 3)
13649 {
13650
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<MAXGUYS; i++)
13651 {
13652 char tempname[64];
13653
13654 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13655 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13656
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12800 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13657 {
13658 memset(tempname, 0, sizeof(char)*64);
13659 sprintf(tempname, "e%03d", i);
13660 strcpy(guy_string[i], tempname);
13661
13662 continue;
13663 }
13664
13665
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!pfread(tempname, 64, f, keepdata))
13666 {
13667 return qe_invalid;
13668 }
13669
13670 // Don't retain names of uneditable enemy entries!
13671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(keepdata)
13672 {
13673 // for version upgrade to 2.5
13674
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12800 if(guyversion < 23 && i >= 177)
13675 {
13676 // some of the older builds have names such as 'zz123',
13677 // (this order gets messed up with some eXXX and some zzXXX)
13678 // so let's update to the newer naming convection. -Gleeok
13679 char tmpbuf[64];
13680 memset(tmpbuf, 0, sizeof(char)*64);
13681 sprintf(tmpbuf, "zz%03d", i);
13682
13683 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13684 {
13685 memset(tempname, 0, sizeof(char)*64);
13686 sprintf(tempname, "e%03d", i);
13687 }
13688 }
13689
13690
6/6
✓ Branch 0 taken 4425 times.
✓ Branch 1 taken 8375 times.
✓ Branch 2 taken 4200 times.
✓ Branch 3 taken 225 times.
✓ Branch 4 taken 3307 times.
✓ Branch 5 taken 893 times.
12800 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13691 {
13692 11907 strcpy(guy_string[i], tempname);
13693 11907 }
13694 else
13695 {
13696 893 strcpy(guy_string[i],old_guy_string[i]);
13697 }
13698 12800 }
13699 12800 }
13700 25 }
13701 else
13702 {
13703 if(keepdata)
13704 {
13705 for(int32_t i=0; i<eMAXGUYS; i++)
13706 {
13707 sprintf(guy_string[i],"zz%03d",i);
13708 }
13709
13710 for(int32_t i=0; i<OLDMAXGUYS; i++)
13711 {
13712 strcpy(guy_string[i],old_guy_string[i]);
13713 }
13714 }
13715 }
13716
13717
13718 //finally... section data
13719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
13720 {
13721 25 init_guys(guyversion); //using default data for now...
13722
13723 // Goriya guy fix
13724
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13725 {
13726 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13727 {
13728 guysbuf[gGORIYA].tile=130;
13729 guysbuf[gGORIYA].e_tile=130;
13730 }
13731 }
13732 25 }
13733
13734
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x193)
13735 {
13736 if(get_bit(deprecated_rules,46))
13737 {
13738 guysbuf[eDODONGO].cset=14;
13739 guysbuf[eDODONGO].bosspal=spDIG;
13740 }
13741 }
13742 // Not sure when this first changed, but it's necessary for 2.10, at least
13743 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13744 //2.10 Fixes
13745
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13746 {
13747 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13748 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13749 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13750 guysbuf[eCENT1].misc3 = 1;
13751 guysbuf[eCENT2].misc3 = 1;
13752 }
13753
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13754 {
13755 25 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13756 25 }
13757
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version <= 0x210)
13758 {
13759 guysbuf[eGLEEOK1F].misc6 = 16;
13760 guysbuf[eGLEEOK2F].misc6 = 16;
13761 guysbuf[eGLEEOK3F].misc6 = 16;
13762 guysbuf[eGLEEOK4F].misc6 = 16;
13763
13764 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13765 guysbuf[eBATROBE].misc4 = 1;
13766 //guysbuf[eSUMMONER].misc4 = 1;
13767 guysbuf[eWWIZ].misc4 = 1;
13768 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13769 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13770 }
13771
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version == 0x190)
13772 {
13773 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13774 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13775 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13776 }
13777
13778 // The versions here may not be correct
13779 // zelda_version>=0x211 handled at guyversion<24
13780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version <= 0x190)
13781 {
13782 guysbuf[eCENT1].misc3 = 0;
13783 guysbuf[eCENT2].misc3 = 0;
13784 guysbuf[eMOLDORM].misc2 = 0;
13785 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13786 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13787 }
13788
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 else if(Header->zelda_version <= 0x210)
13789 {
13790 guysbuf[eCENT1].misc3 = 1;
13791 guysbuf[eCENT2].misc3 = 1;
13792 guysbuf[eMOLDORM].misc2 = 0;
13793 }
13794
13795
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13796 {
13797 guysbuf[eKEESE1].misc16 = 120;
13798 guysbuf[eKEESE2].misc16 = 120;
13799 guysbuf[eKEESE3].misc16 = 120;
13800 guysbuf[eKEESETRIB].misc16 = 120;
13801 guysbuf[eKEESE1].misc17 = 16;
13802 guysbuf[eKEESE2].misc17 = 16;
13803 guysbuf[eKEESE3].misc17 = 16;
13804 guysbuf[eKEESETRIB].misc17 = 16;
13805
13806 guysbuf[ePEAHAT].misc16 = 80;
13807 guysbuf[ePEAHAT].misc17 = 16;
13808
13809 guysbuf[eGHINI2].misc16 = 120;
13810 guysbuf[eGHINI2].misc17 = 10;
13811
13812 }
13813
13814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(guyversion<=2)
13815 {
13816 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13817 }
13818
13819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(guyversion > 3)
13820 {
13821 guydata tempguy;
13822
13823
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<MAXGUYS; i++)
13824 {
13825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12800 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13826 {
13827 if(i >= OLDBETAMAXGUYS)
13828 {
13829 memset(&guysbuf[i], 0, sizeof(guydata));
13830 continue;
13831 }
13832 }
13833
13834 12800 memset(&tempguy, 0, sizeof(guydata));
13835
13836
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.flags),f,keepdata))
13837 {
13838 return qe_invalid;
13839 }
13840
13841
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.flags2),f,keepdata))
13842 {
13843 return qe_invalid;
13844 }
13845
13846
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( guyversion >= 36 ) //expanded tiles
13847 {
13848
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.tile),f,keepdata))
13849 {
13850 return qe_invalid;
13851 }
13852 512 }
13853 else
13854 {
13855
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&(tempguy.tile),f,keepdata))
13856 {
13857 return qe_invalid;
13858 }
13859 }
13860
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.width),f,keepdata))
13861 {
13862 return qe_invalid;
13863 }
13864
13865
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.height),f,keepdata))
13866 {
13867 return qe_invalid;
13868 }
13869
13870
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( guyversion >= 36 ) //expanded tiles
13871 {
13872
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
13873 {
13874 return qe_invalid;
13875 }
13876 512 }
13877 else
13878 {
13879
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
13880 {
13881 return qe_invalid;
13882 }
13883 }
13884
13885
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.s_width),f,keepdata))
13886 {
13887 return qe_invalid;
13888 }
13889
13890
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.s_height),f,keepdata))
13891 {
13892 return qe_invalid;
13893 }
13894
13895
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( guyversion >= 36 ) //expanded tiles
13896 {
13897
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
13898 {
13899 return qe_invalid;
13900 }
13901 512 }
13902 else
13903 {
13904
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
13905 {
13906 return qe_invalid;
13907 }
13908 }
13909
13910
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.e_width),f,keepdata))
13911 {
13912 return qe_invalid;
13913 }
13914
13915
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.e_height),f,keepdata))
13916 {
13917 return qe_invalid;
13918 }
13919
13920
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.hp),f,keepdata))
13921 {
13922 return qe_invalid;
13923 }
13924
13925
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.family),f,keepdata))
13926 {
13927 return qe_invalid;
13928 }
13929
13930
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
12800 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13931 {
13932 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13933 {
13934 tempguy.s_tile=tempguy.e_tile+120;
13935 tempguy.s_width=tempguy.e_width;
13936 tempguy.s_height=tempguy.e_height;
13937 }
13938 else tempguy.s_tile=860;
13939 }
13940
13941
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.cset),f,keepdata))
13942 {
13943 return qe_invalid;
13944 }
13945
13946
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.anim),f,keepdata))
13947 {
13948 return qe_invalid;
13949 }
13950
13951
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
13952 {
13953 return qe_invalid;
13954 }
13955
13956
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.frate),f,keepdata))
13957 {
13958 return qe_invalid;
13959 }
13960
13961
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
13962 {
13963 return qe_invalid;
13964 }
13965
13966
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 13) // April 2009
13967 {
13968 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13969 {
13970 tempguy.frate *= 2;
13971 tempguy.e_frate *= 2;
13972 }
13973 }
13974
13975
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 14) // May 1 2009
13976 {
13977 if(tempguy.anim==a2FRMSLOW)
13978 {
13979 tempguy.anim=a2FRM;
13980 tempguy.frate *= 2;
13981 }
13982
13983 if(tempguy.e_anim==a2FRMSLOW)
13984 {
13985 tempguy.e_anim=a2FRM;
13986 tempguy.e_frate *= 2;
13987 }
13988
13989 if(tempguy.anim==aFLIPSLOW)
13990 {
13991 tempguy.anim=aFLIP;
13992 tempguy.frate *= 2;
13993 }
13994
13995 if(tempguy.e_anim==aFLIPSLOW)
13996 {
13997 tempguy.e_anim=aFLIP;
13998 tempguy.e_frate *= 2;
13999 }
14000
14001 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14002
14003 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14004
14005 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14006 {
14007 tempguy.anim=a4FRM4DIR;
14008 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14009 }
14010
14011 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14012 {
14013 tempguy.e_anim=a4FRM4DIR;
14014 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14015 }
14016 }
14017
14018
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.dp),f,keepdata))
14019 {
14020 return qe_invalid;
14021 }
14022
14023 //correction for guy fire
14024
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 6)
14025 {
14026 if(i == gFIRE)
14027 tempguy.dp = 2;
14028 }
14029
14030
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14031 {
14032 return qe_invalid;
14033 }
14034
14035
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14036 {
14037 return qe_invalid;
14038 }
14039
14040 //correction for bosses using triple, "rising" fireballs
14041
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 5)
14042 {
14043 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14044 i == eGOHMA3 || i == eGOHMA4)
14045 {
14046 if(tempguy.weapon == ewFireball)
14047 tempguy.weapon = ewFireball2;
14048 }
14049 }
14050
14051
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.rate),f,keepdata))
14052 {
14053 return qe_invalid;
14054 }
14055
14056
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14057 {
14058 return qe_invalid;
14059 }
14060
14061
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.step),f,keepdata))
14062 {
14063 return qe_invalid;
14064 }
14065
14066 // HIGHLY UNORTHODOX UPDATING THING, part 2
14067
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12800 if(fixpolsvoice && tempguy.family==eePOLSV)
14068 {
14069 tempguy.step /= 2;
14070 }
14071
14072
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.homing),f,keepdata))
14073 {
14074 return qe_invalid;
14075 }
14076
14077
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14078 {
14079 return qe_invalid;
14080 }
14081
14082
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14083 {
14084 return qe_invalid;
14085 }
14086
14087
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14088 {
14089
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14090 {
14091 return qe_invalid;
14092 }
14093
14094
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14095 {
14096 return qe_invalid;
14097 }
14098
14099
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14100 {
14101 return qe_invalid;
14102 }
14103
14104
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14105 {
14106 return qe_invalid;
14107 }
14108
14109
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14110 {
14111 return qe_invalid;
14112 }
14113
14114
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14115 {
14116 return qe_invalid;
14117 }
14118
14119
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14120 {
14121 return qe_invalid;
14122 }
14123
14124
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14125 {
14126 return qe_invalid;
14127 }
14128
14129
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14130 {
14131 return qe_invalid;
14132 }
14133
14134
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14135 {
14136 return qe_invalid;
14137 }
14138 12800 }
14139 else
14140 {
14141 int16_t tempMisc;
14142
14143 if(!p_igetw(&tempMisc,f,keepdata))
14144 {
14145 return qe_invalid;
14146 }
14147
14148 tempguy.misc1=tempMisc;
14149
14150 if(!p_igetw(&tempMisc,f,keepdata))
14151 {
14152 return qe_invalid;
14153 }
14154
14155 tempguy.misc2=tempMisc;
14156
14157 if(!p_igetw(&tempMisc,f,keepdata))
14158 {
14159 return qe_invalid;
14160 }
14161
14162 tempguy.misc3=tempMisc;
14163
14164 if(!p_igetw(&tempMisc,f,keepdata))
14165 {
14166 return qe_invalid;
14167 }
14168
14169 tempguy.misc4=tempMisc;
14170
14171 if(!p_igetw(&tempMisc,f,keepdata))
14172 {
14173 return qe_invalid;
14174 }
14175
14176 tempguy.misc5=tempMisc;
14177
14178 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14179 {
14180 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14181 tempguy.misc5 = 74;
14182 }
14183
14184 if(!p_igetw(&tempMisc,f,keepdata))
14185 {
14186 return qe_invalid;
14187 }
14188
14189 tempguy.misc6=tempMisc;
14190
14191 if(!p_igetw(&tempMisc,f,keepdata))
14192 {
14193 return qe_invalid;
14194 }
14195
14196 tempguy.misc7=tempMisc;
14197
14198 if(!p_igetw(&tempMisc,f,keepdata))
14199 {
14200 return qe_invalid;
14201 }
14202
14203 tempguy.misc8=tempMisc;
14204
14205 if(!p_igetw(&tempMisc,f,keepdata))
14206 {
14207 return qe_invalid;
14208 }
14209
14210 tempguy.misc9=tempMisc;
14211
14212 if(!p_igetw(&tempMisc,f,keepdata))
14213 {
14214 return qe_invalid;
14215 }
14216
14217 tempguy.misc10=tempMisc;
14218 }
14219
14220
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14221 {
14222 return qe_invalid;
14223 }
14224
14225
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14226 {
14227 return qe_invalid;
14228 }
14229
14230
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.extend),f,keepdata))
14231 {
14232 return qe_invalid;
14233 }
14234
14235 //! Enemy Defences
14236
14237 //If a 2.50 quest, use only the 2.5 defences.
14238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14239 {
14240
2/2
✓ Branch 0 taken 243200 times.
✓ Branch 1 taken 12800 times.
256000 for(int32_t j=0; j<edefLAST; j++)
14241 {
14242
1/2
✓ Branch 0 taken 243200 times.
✗ Branch 1 not taken.
243200 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14243 {
14244 return qe_invalid;
14245 }
14246 243200 }
14247 //then copy the generic script defence to all the new script defences
14248
14249 12800 }
14250
14251
14252
14253
14254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(guyversion >= 18)
14255 {
14256
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14257 {
14258 return qe_invalid;
14259 }
14260
14261
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14262 {
14263 return qe_invalid;
14264 }
14265 12800 }
14266
14267
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion >= 22)
14268 {
14269
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14270 {
14271 return qe_invalid;
14272 }
14273
14274
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14275 {
14276 return qe_invalid;
14277 }
14278 12800 }
14279 else if(guyversion >= 19)
14280 {
14281 int16_t tempMisc;
14282
14283 if(!p_igetw(&tempMisc,f,keepdata))
14284 {
14285 return qe_invalid;
14286 }
14287
14288 tempguy.misc11=tempMisc;
14289
14290 if(!p_igetw(&tempMisc,f,keepdata))
14291 {
14292 return qe_invalid;
14293 }
14294
14295 tempguy.misc12=tempMisc;
14296 }
14297
14298 //If a 2.54 or later quest, use all of the defences.
14299
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(guyversion > 24) // Add new guyversion conditional statement
14300 {
14301
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 512 times.
11776 for(int32_t j=edefLAST; j<edefLAST255; j++)
14302 {
14303
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14304 {
14305 return qe_invalid;
14306 }
14307 11264 }
14308 512 }
14309
14310
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14311 {
14312
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 12288 times.
135168 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14313 {
14314 122880 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14315 122880 }
14316 12288 }
14317
14318 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14319
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(guyversion > 25)
14320 {
14321
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14322 {
14323 return qe_invalid;
14324 }
14325
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14326 {
14327 return qe_invalid;
14328 }
14329
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14330 {
14331 return qe_invalid;
14332 }
14333
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14334 {
14335 return qe_invalid;
14336 }
14337
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14338 {
14339 return qe_invalid;
14340 }
14341 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14342
14343 */
14344 512 }
14345 //More Enemy Editor vars for 2.60
14346
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(guyversion > 26)
14347 {
14348
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14349 {
14350 return qe_invalid;
14351 }
14352
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14353 {
14354 return qe_invalid;
14355 }
14356
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14357 {
14358 return qe_invalid;
14359 }
14360
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14361 {
14362 return qe_invalid;
14363 }
14364
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14365 {
14366 return qe_invalid;
14367 }
14368 512 }
14369
14370
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14371 {
14372 12288 tempguy.wpnsprite = 0;
14373 12288 }
14374
14375
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(guyversion > 27)
14376 {
14377
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14378 {
14379 return qe_invalid;
14380 }
14381 512 }
14382
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14383 {
14384 12288 tempguy.SIZEflags = 0;
14385 12288 }
14386
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(guyversion > 28)
14387 {
14388
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14389 {
14390 return qe_invalid;
14391 }
14392
14393 512 }
14394
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14395 {
14396 12288 tempguy.frozentile = 0;
14397 12288 tempguy.frozencset = 0;
14398 12288 tempguy.frozenclock = 0;
14399
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 12288 times.
135168 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14400 12288 }
14401
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(guyversion >= 30)
14402 {
14403
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14404 {
14405 return qe_invalid;
14406 }
14407
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14408 {
14409 return qe_invalid;
14410 }
14411
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14412 {
14413 return qe_invalid;
14414 }
14415
2/2
✓ Branch 0 taken 5120 times.
✓ Branch 1 taken 512 times.
5632 for ( int32_t q = 0; q < 10; q++ ) {
14416
1/2
✓ Branch 0 taken 5120 times.
✗ Branch 1 not taken.
5120 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14417 {
14418 return qe_invalid;
14419 }
14420 5120 }
14421
14422 512 }
14423
14424
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(guyversion >= 34)
14425 {
14426
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14427 {
14428 return qe_invalid;
14429 }
14430
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14431 {
14432 return qe_invalid;
14433 }
14434
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14435 {
14436 return qe_invalid;
14437 }
14438
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14439 {
14440 return qe_invalid;
14441 }
14442
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14443 {
14444 return qe_invalid;
14445 }
14446
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14447 {
14448 return qe_invalid;
14449 }
14450
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14451 {
14452 return qe_invalid;
14453 }
14454
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14455 {
14456 return qe_invalid;
14457 }
14458
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14459 {
14460 return qe_invalid;
14461 }
14462
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14463 {
14464 return qe_invalid;
14465 }
14466
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14467 {
14468 return qe_invalid;
14469 }
14470
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14471 {
14472 return qe_invalid;
14473 }
14474
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14475 {
14476 return qe_invalid;
14477 }
14478
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14479 {
14480 return qe_invalid;
14481 }
14482
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14483 {
14484 return qe_invalid;
14485 }
14486
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14487 {
14488 return qe_invalid;
14489 }
14490
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14491 {
14492 return qe_invalid;
14493 }
14494
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14495 {
14496 return qe_invalid;
14497 }
14498
14499
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 512 times.
16896 for ( int32_t q = 0; q < 32; q++ ) {
14500
1/2
✓ Branch 0 taken 16384 times.
✗ Branch 1 not taken.
16384 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14501 {
14502 return qe_invalid;
14503 }
14504 16384 }
14505
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 512 times.
16896 for ( int32_t q = 0; q < 32; q++ ) {
14506
1/2
✓ Branch 0 taken 16384 times.
✗ Branch 1 not taken.
16384 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14507 {
14508 return qe_invalid;
14509 }
14510 16384 }
14511
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&(tempguy.script),f,keepdata))
14512 {
14513 return qe_invalid;
14514 }
14515 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14516
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for ( int32_t q = 0; q < 8; q++ )
14517 {
14518
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14519 {
14520 return qe_invalid;
14521 }
14522 4096 }
14523
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 512 times.
1536 for ( int32_t q = 0; q < 2; q++ )
14524 {
14525
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14526 {
14527 return qe_invalid;
14528 }
14529 1024 }
14530
14531 512 }
14532
14533
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(guyversion >= 37)
14534 {
14535
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14536 {
14537 return qe_invalid;
14538 }
14539 512 }
14540
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14541
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if(guyversion >= 38)
14542 {
14543
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14544 {
14545 return qe_invalid;
14546 }
14547
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14548 {
14549 return qe_invalid;
14550 }
14551
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14552 {
14553 return qe_invalid;
14554 }
14555
14556 512 }
14557
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( guyversion < 38 )
14558 {
14559 12288 tempguy.misc13 = 0;
14560 12288 tempguy.misc14 = 0;
14561 12288 tempguy.misc15 = 0;
14562 12288 }
14563
14564
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if ( guyversion >= 39 )
14565 {
14566
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for ( int32_t q = 0; q < 8; q++ )
14567 {
14568
2/2
✓ Branch 0 taken 266240 times.
✓ Branch 1 taken 4096 times.
270336 for ( int32_t w = 0; w < 65; w++ )
14569 {
14570
1/2
✓ Branch 0 taken 266240 times.
✗ Branch 1 not taken.
266240 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14571 {
14572 return qe_invalid;
14573 }
14574 266240 }
14575
2/2
✓ Branch 0 taken 266240 times.
✓ Branch 1 taken 4096 times.
270336 for ( int32_t w = 0; w < 65; w++ )
14576 {
14577
1/2
✓ Branch 0 taken 266240 times.
✗ Branch 1 not taken.
266240 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14578 {
14579 return qe_invalid;
14580 }
14581 266240 }
14582 4096 }
14583
14584
14585 512 }
14586
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( guyversion < 39 ) //apply old InitD strings to both
14587 {
14588 12288 al_trace("Populating InitD Label Fields for NPCS\n");
14589
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; q++ )
14590 {
14591 98304 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14592 98304 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14593 98304 }
14594 12288 }
14595
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if ( guyversion >= 40 )
14596 {
14597
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14598 {
14599 return qe_invalid;
14600 }
14601 512 }
14602
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if ( guyversion < 40 )
14603 {
14604 12288 tempguy.weaponscript = 0;
14605 12288 }
14606 //eweapon script InitD
14607
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
12800 if ( guyversion >= 41 )
14608 {
14609
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for ( int32_t q = 0; q < 8; q++ )
14610 {
14611
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14612 {
14613 return qe_invalid;
14614 }
14615 4096 }
14616
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if ( guy_cversion < 4 )
14617 {
14618 if ( tempguy.family == eeKEESE )
14619 {
14620
14621 if ( !tempguy.misc1 )
14622 {
14623 tempguy.misc16 = 120;
14624 tempguy.misc17 = 16;
14625
14626 }
14627 }
14628 if ( tempguy.family == eePEAHAT )
14629 {
14630 tempguy.misc16 = 80;
14631 tempguy.misc17 = 16;
14632 }
14633
14634 if ( tempguy.family == eeGHINI )
14635 {
14636 tempguy.misc16 = 120;
14637 tempguy.misc17 = 10;
14638 }
14639
14640 }
14641 512 }
14642
14643
14644
14645 //default weapon sprites (quest version < 2.54)
14646 //port over old defaults -Z
14647
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion < 32)
14648 {
14649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if ( tempguy.wpnsprite <= 0 )
14650 {
14651
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10414 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 259 times.
✓ Branch 7 taken 134 times.
✓ Branch 8 taken 253 times.
✓ Branch 9 taken 24 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 46 times.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 101 times.
✓ Branch 14 taken 227 times.
✓ Branch 15 taken 30 times.
✓ Branch 16 taken 24 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 227 times.
12288 switch(tempguy.weapon)
14652 {
14653 case wNone:
14654 10414 tempguy.wpnsprite = 0; break;
14655
14656 case wSword:
14657 case wBeam:
14658 case wBrang:
14659 case wBomb:
14660 case wSBomb:
14661 case wLitBomb:
14662 case wLitSBomb:
14663 case wArrow:
14664 case wFire:
14665 case wWhistle:
14666 case wBait:
14667 case wWand:
14668 case wMagic:
14669 case wCatching:
14670 case wWind:
14671 case wRefMagic:
14672 case wRefFireball:
14673 case wRefRock:
14674 case wHammer:
14675 case wHookshot:
14676 case wHSHandle:
14677 case wHSChain:
14678 case wSSparkle:
14679 case wFSparkle:
14680 case wSmack:
14681 case wPhantom:
14682 case wCByrna:
14683 case wRefBeam:
14684 case wStomp:
14685 case lwMax:
14686 case wScript1:
14687 case wScript2:
14688 case wScript3:
14689 case wScript4:
14690 case wScript5:
14691 case wScript6:
14692 case wScript7:
14693 case wScript8:
14694 case wScript9:
14695 case wScript10:
14696 case wIce:
14697 //Cannot use any of these weapons yet.
14698 tempguy.wpnsprite = -1;
14699 break;
14700
14701 case wEnemyWeapons:
14702 373 case ewFireball: tempguy.wpnsprite = 17; break;
14703
14704 82 case ewArrow: tempguy.wpnsprite = 19; break;
14705 90 case ewBrang: tempguy.wpnsprite = 4; break;
14706 259 case ewSword: tempguy.wpnsprite = 20; break;
14707 134 case ewRock: tempguy.wpnsprite = 18; break;
14708 253 case ewMagic: tempguy.wpnsprite = 21; break;
14709 24 case ewBomb: tempguy.wpnsprite = 78; break;
14710 2 case ewSBomb: tempguy.wpnsprite = 79; break;
14711 46 case ewLitBomb: tempguy.wpnsprite = 76; break;
14712 2 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14713 101 case ewFireTrail: tempguy.wpnsprite = 80; break;
14714 227 case ewFlame: tempguy.wpnsprite = 35; break;
14715 30 case ewWind: tempguy.wpnsprite = 36; break;
14716 24 case ewFlame2: tempguy.wpnsprite = 81; break;
14717 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14718 case ewIce: tempguy.wpnsprite = 83; break;
14719 227 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14720
14721
14722 default: break; //No assign.
14723 }
14724 12288 }
14725 12288 }
14726
14727 //default weapon fire sound (quest version < 2.54)
14728 //port over old defaults and zero new data. -Z
14729
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion < 34)
14730 {
14731
2/2
✓ Branch 0 taken 393216 times.
✓ Branch 1 taken 12288 times.
405504 for ( int32_t q = 0; q < 32; q++ )
14732 {
14733 393216 tempguy.movement[q] = 0;
14734 393216 tempguy.new_weapon[q] = 0;
14735
14736 393216 }
14737
14738 //NPC Script attributes.
14739 12288 tempguy.script = 0; //No scripted enemies existed. -Z
14740
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14741
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 12288 times.
36864 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14742
14743 12288 tempguy.misc16 = 0;
14744 12288 tempguy.misc17 = 0;
14745 12288 tempguy.misc18 = 0;
14746 12288 tempguy.misc19 = 0;
14747 12288 tempguy.misc20 = 0;
14748 12288 tempguy.misc21 = 0;
14749 12288 tempguy.misc22 = 0;
14750 12288 tempguy.misc23 = 0;
14751 12288 tempguy.misc24 = 0;
14752 12288 tempguy.misc25 = 0;
14753 12288 tempguy.misc26 = 0;
14754 12288 tempguy.misc27 = 0;
14755 12288 tempguy.misc28 = 0;
14756 12288 tempguy.misc29 = 0;
14757 12288 tempguy.misc30 = 0;
14758 12288 tempguy.misc31 = 0;
14759 12288 tempguy.misc32 = 0;
14760
14761 //old default sounds
14762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if ( tempguy.firesfx <= 0 )
14763 {
14764
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10414 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 259 times.
✓ Branch 7 taken 134 times.
✓ Branch 8 taken 253 times.
✓ Branch 9 taken 24 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 46 times.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 101 times.
✓ Branch 14 taken 227 times.
✓ Branch 15 taken 30 times.
✓ Branch 16 taken 24 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 227 times.
12288 switch(tempguy.weapon)
14765 {
14766 case wNone:
14767 10414 tempguy.firesfx = 0; break;
14768
14769 case wSword:
14770 case wBeam:
14771 case wBrang:
14772 case wBomb:
14773 case wSBomb:
14774 case wLitBomb:
14775 case wLitSBomb:
14776 case wArrow:
14777 case wFire:
14778 case wWhistle:
14779 case wBait:
14780 case wWand:
14781 case wMagic:
14782 case wCatching:
14783 case wWind:
14784 case wRefMagic:
14785 case wRefFireball:
14786 case wRefRock:
14787 case wHammer:
14788 case wHookshot:
14789 case wHSHandle:
14790 case wHSChain:
14791 case wSSparkle:
14792 case wFSparkle:
14793 case wSmack:
14794 case wPhantom:
14795 case wCByrna:
14796 case wRefBeam:
14797 case wStomp:
14798 case lwMax:
14799 case wScript1:
14800 case wScript2:
14801 case wScript3:
14802 case wScript4:
14803 case wScript5:
14804 case wScript6:
14805 case wScript7:
14806 case wScript8:
14807 case wScript9:
14808 case wScript10:
14809 case wIce:
14810 //Cannot use any of these weapons yet.
14811 tempguy.firesfx = -1;
14812 break;
14813
14814 case wEnemyWeapons:
14815 373 case ewFireball: tempguy.firesfx = 40; break;
14816
14817 82 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14818 90 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14819 259 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14820 134 case ewRock: tempguy.firesfx = 51; break;
14821 253 case ewMagic: tempguy.firesfx = 32; break;
14822 24 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14823 2 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14824 46 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14825 2 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14826 101 case ewFireTrail: tempguy.firesfx = 13; break;
14827 227 case ewFlame: tempguy.firesfx = 13; break;
14828 30 case ewWind: tempguy.firesfx = 32; break;
14829 24 case ewFlame2: tempguy.firesfx = 13; break;
14830 case ewFlame2Trail: tempguy.firesfx = 13; break;
14831 case ewIce: tempguy.firesfx = 44; break;
14832 227 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14833
14834 //what about special attacks (e.g. summoning == 56)
14835 default: break; //No assign.
14836 }
14837 12288 }
14838 12288 }
14839
14840 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14841
4/6
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 512 times.
12800 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14842 {
14843
2/2
✓ Branch 0 taken 876 times.
✓ Branch 1 taken 11412 times.
12288 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14844 12288 }
14845 //Keese and bat halt rates.
14846
3/4
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12288 times.
12800 if ( guyversion < 42 && guy_cversion < 4 )
14847 {
14848
14849
2/2
✓ Branch 0 taken 12132 times.
✓ Branch 1 taken 156 times.
12288 if ( tempguy.family == eeKEESE )
14850 {
14851
14852
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 98 times.
156 if ( !tempguy.misc1 )
14853 {
14854 98 tempguy.misc16 = 120;
14855 98 tempguy.misc17 = 16;
14856
14857 98 }
14858 156 }
14859
2/2
✓ Branch 0 taken 12237 times.
✓ Branch 1 taken 51 times.
12288 if ( tempguy.family == eePEAHAT )
14860 {
14861 51 tempguy.misc16 = 80;
14862 51 tempguy.misc17 = 16;
14863 51 }
14864
2/2
✓ Branch 0 taken 12264 times.
✓ Branch 1 taken 24 times.
12288 if ( tempguy.family == eeGHINI )
14865 {
14866 24 tempguy.misc16 = 120;
14867 24 tempguy.misc17 = 10;
14868 24 }
14869
14870
14871 12288 }
14872
14873
14874 //miscellaneous other corrections
14875 //fix the mirror wizzrobe -DD
14876
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 7)
14877 {
14878 if(i == eMWIZ)
14879 {
14880 tempguy.misc2 = 0;
14881 tempguy.misc4 = 1;
14882 }
14883 }
14884
14885
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 8)
14886 {
14887 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14888 {
14889 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14890 tempguy.misc5 = 4; //neck length in segments
14891 tempguy.misc6 = 8; //neck offset from first body tile
14892 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14893 tempguy.misc8 = 168; //head offset from first body tile
14894 tempguy.misc9 = 228; //flying head offset from first body tile
14895
14896 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14897 {
14898 tempguy.misc6 += 10; //neck offset from first body tile
14899 tempguy.misc8 -= 12; //head offset from first body tile
14900 }
14901 }
14902 }
14903
14904
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14905 {
14906 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14907 tempguy.bosspal = spDIG;
14908 }
14909
14910
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 11) // December 2007 - Spinning Tile fix
14911 {
14912 if(tempguy.family==eeSPINTILE)
14913 {
14914 tempguy.flags |= guy_superman;
14915 tempguy.item_set = 0; // Don't drop items
14916 tempguy.step = 300;
14917 }
14918 }
14919
14920
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14921 {
14922 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14923 {
14924 if(tempguy.family==eeROPE)
14925 {
14926 tempguy.flags2 &= ~guy_flashing;
14927 }
14928 }
14929
14930 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14931 {
14932 if(tempguy.family==eeBUBBLE)
14933 {
14934 tempguy.flags2 &= ~guy_flashing;
14935 }
14936 }
14937
14938 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14939 {
14940 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14941 {
14942 tempguy.flags2 |= guy_blinking;
14943 }
14944
14945 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14946 {
14947 tempguy.flags2 |= guy_transparent;
14948 }
14949 }
14950 }
14951
14952
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14953 {
14954 if(i==gFIRE)
14955 {
14956 tempguy.e_anim = aFLIP;
14957 tempguy.e_frate = 24;
14958 }
14959
14960 if(i==gFAIRY)
14961 {
14962 tempguy.e_anim = a2FRM;
14963 tempguy.e_frate = 16;
14964 }
14965 }
14966
14967
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14968 {
14969 if(i==0) Z_message("Updating guys to version 16...\n");
14970
14971 update_guy_1(&tempguy);
14972
14973 if(i==eMPOLSV)
14974 {
14975 tempguy.defense[edefARROW] = edCHINK;
14976 tempguy.defense[edefMAGIC] = ed1HKO;
14977 tempguy.defense[edefREFMAGIC] = ed1HKO;
14978 }
14979 }
14980
14981
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 17) // December 2009
14982 {
14983 if(tempguy.family==eePROJECTILE)
14984 {
14985 tempguy.misc1 = 0;
14986 }
14987 }
14988
14989
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 18) // January 2010
14990 {
14991 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14992 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14993
14994 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14995 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14996
14997 if(tempguy.family == eeAQUA)
14998 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14999 else if(tempguy.family == eeMANHAN)
15000 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15001 else if(tempguy.family==eePATRA)
15002 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15003 else if(tempguy.family==eeGHOMA)
15004 {
15005 for(int32_t j=0; j<edefLAST; j++)
15006 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15007
15008 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15009
15010 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15011
15012 tempguy.misc1--;
15013 }
15014 else if(tempguy.family == eeGLEEOK)
15015 {
15016 for(int32_t j=0; j<edefLAST; j++)
15017 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15018
15019 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15020 }
15021 else if(tempguy.family == eeARMOS)
15022 {
15023 tempguy.family=eeWALK;
15024 tempguy.hrate = 0;
15025 tempguy.misc10 = tempguy.misc1;
15026 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15027 tempguy.misc9 = e9tARMOS;
15028 }
15029 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15030 {
15031 tempguy.family=eeWALK;
15032 tempguy.hrate = 0;
15033 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15034 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15035 }
15036
15037 // Spawn animation flags
15038 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15039 tempguy.flags |= guy_fadeflicker;
15040 else
15041 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15042 }
15043
15044
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 20) // April 2010
15045 {
15046 if(tempguy.family == eeTRAP)
15047 {
15048 tempguy.misc2 = tempguy.misc10;
15049
15050 if(tempguy.misc10>=1)
15051 {
15052 tempguy.misc1++;
15053 }
15054
15055 tempguy.misc10 = 0;
15056 }
15057
15058 // Bomb Blast fix
15059 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15060 tempguy.weapon = ewLitBomb;
15061 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15062 tempguy.weapon = ewLitSBomb;
15063 }
15064
15065
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 21) // September 2011
15066 {
15067 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15068 {
15069 if(tempguy.family == eeKEESETRIB)
15070 {
15071 tempguy.family = eeKEESE;
15072 tempguy.misc2 = e2tKEESETRIB;
15073 tempguy.misc1 = 0;
15074 }
15075
15076 tempguy.rate = 2;
15077 tempguy.hrate = 8;
15078 tempguy.homing = 0;
15079 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15080 }
15081 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15082 {
15083 if(tempguy.family == eePEAHAT)
15084 {
15085 tempguy.rate = 4;
15086 tempguy.step = 62;
15087 }
15088 else
15089 tempguy.step = 25;
15090
15091 tempguy.hrate = 8;
15092 tempguy.homing = 0;
15093 }
15094 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15095 {
15096 if(tempguy.family == eeMANHAN)
15097 tempguy.step=50;
15098
15099 tempguy.hrate = 16;
15100 tempguy.homing = 0;
15101 }
15102 else if(tempguy.family == eeGLEEOK)
15103 {
15104 tempguy.rate = 2;
15105 tempguy.homing = 0;
15106 tempguy.hrate = 9;
15107 tempguy.step=89;
15108 }
15109 else if(tempguy.family == eeGHINI)
15110 {
15111 tempguy.rate = 4;
15112 tempguy.hrate = 12;
15113 tempguy.step=62;
15114 tempguy.homing = 0;
15115 }
15116
15117 // Bigdig random rate fix
15118 if(tempguy.family==eeDIG && tempguy.misc10==1)
15119 {
15120 tempguy.rate = 2;
15121 }
15122 }
15123
15124
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(guyversion < 24) // November 2012
15125 {
15126 if(tempguy.family==eeLANM)
15127 tempguy.misc3 = 1;
15128 else if(tempguy.family==eeMOLD)
15129 tempguy.misc2 = 0;
15130 }
15131
15132
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15133 {
15134
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 12087 times.
12288 if(tempguy.family!=eeDIG)
15135 {
15136 12087 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15137 12087 }
15138
15139 12288 }
15140 // does not seem to solve the issue!
15141
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if ( Header->zelda_version <= 0x210 )
15142 {
15143 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15144 if ( tempguy.family == eeDONGO )
15145 {
15146 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15147 }
15148 }
15149
15150
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion >= 42)
15151 {
15152
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(guyversion >= 47)
15153 {
15154
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15155 {
15156 return qe_invalid;
15157 }
15158 512 }
15159 else
15160 {
15161 byte fl;
15162 if(!p_getc(&fl,f,keepdata))
15163 {
15164 return qe_invalid;
15165 }
15166 tempguy.moveflags = fl;
15167 }
15168 512 }
15169 else
15170 {
15171
7/8
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 10071 times.
✓ Branch 2 taken 333 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 79 times.
✓ Branch 6 taken 66 times.
✓ Branch 7 taken 1620 times.
12288 switch(tempguy.family)
15172 {
15173 //No gravity; floats over pits
15174 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15175 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15176 //Special (bosses, etc)
15177 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15178 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15179 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15180 10071 tempguy.moveflags = FLAG_CAN_PITWALK;
15181 10071 break;
15182 //No gravity, but falls in pits
15183 case eeLEV:
15184 104 tempguy.moveflags = FLAG_CAN_PITFALL;
15185 104 break;
15186 //Bosses that respect pits
15187 case eeDONGO:
15188 79 tempguy.moveflags = FLAG_OBEYS_GRAV;
15189 79 break;
15190 case eeLANM:
15191 66 tempguy.moveflags = 0;
15192 66 break;
15193 //Gravity, floats over pits
15194 case eeWIZZ: case eeWALLM: case eeGHINI:
15195 333 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15196 333 break;
15197 //Gravity and falls in pits
15198 case eeWALK:
15199
4/4
✓ Branch 0 taken 1525 times.
✓ Branch 1 taken 95 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 1457 times.
1620 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15200 163 break;
15201 [[fallthrough]];
15202 case eeOTHER:
15203 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15204 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15205 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15206 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15207 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15208 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15209 1472 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15210 1472 }
15211 }
15212
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion < 43)
15213 {
15214
2/2
✓ Branch 0 taken 10404 times.
✓ Branch 1 taken 1884 times.
12288 switch(tempguy.family)
15215 {
15216 //No gravity; floats over pits
15217 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15218 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15219 //Special (bosses, etc)
15220 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15221 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15222 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15223 case eeWIZZ: case eeWALLM: case eeGHINI:
15224 //Gravity, floats over pits
15225 10404 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15226 10404 break;
15227 }
15228 12288 }
15229
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if (guyversion < 44)
15230 {
15231
2/2
✓ Branch 0 taken 12171 times.
✓ Branch 1 taken 117 times.
12288 if ( tempguy.family == eeGHOMA )
15232 {
15233 117 tempguy.flags |= guy_fadeinstant;
15234 117 }
15235 12288 }
15236
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if (guyversion > 44)
15237 {
15238
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15239 {
15240 return qe_invalid;
15241 }
15242
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15243 {
15244 return qe_invalid;
15245 }
15246
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15247 {
15248 return qe_invalid;
15249 }
15250 512 }
15251 else
15252 {
15253
2/2
✓ Branch 0 taken 12240 times.
✓ Branch 1 taken 48 times.
12288 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15254 12288 tempguy.spr_death = iwDeath;
15255 12288 tempguy.spr_spawn = iwSpawn;
15256 }
15257
15258
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 12288 times.
12800 if(guyversion < 46)
15259 {
15260
4/4
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 10668 times.
✓ Branch 2 taken 1525 times.
✓ Branch 3 taken 95 times.
12288 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15261 {
15262 95 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15263 95 }
15264 12288 }
15265
15266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(keepdata)
15267 {
15268 12800 guysbuf[i] = tempguy;
15269 12800 }
15270 12800 }
15271 25 }
15272
15273 25 return 0;
15274 25 }
15275
15276 void update_guy_1(guydata *tempguy) // November 2009
15277 {
15278 bool doesntcount = false;
15279 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15280
15281 switch(tempguy->family)
15282 {
15283 case 1: //eeWALK
15284 switch(tempguy->misc10)
15285 {
15286 case 0: //Stalfos
15287 if(tempguy->misc1==1) // Fires four projectiles at once
15288 tempguy->misc1=4;
15289
15290 break;
15291
15292 case 1: //Darknut
15293 goto darknuts;
15294 break;
15295 }
15296
15297 tempguy->misc10 = 0;
15298 break;
15299
15300 case 2: //eeSHOOT
15301 tempguy->family = eeWALK;
15302
15303 switch(tempguy->misc10)
15304 {
15305 case 0: //Octorok
15306 if(tempguy->misc1==1||tempguy->misc1==2)
15307 {
15308 tempguy->misc1=e1tFIREOCTO;
15309 tempguy->misc2=e2tFIREOCTO;
15310 }
15311 else tempguy->misc1 = 0;
15312
15313 tempguy->misc6=tempguy->misc4;
15314 tempguy->misc4=tempguy->misc3;
15315 tempguy->misc3=0;
15316 break;
15317
15318 case 1: // Moblin
15319 tempguy->misc1 = 0;
15320 break;
15321
15322 case 2: //Lynel
15323 tempguy->misc6=tempguy->misc1+1;
15324 tempguy->misc1=0;
15325 break;
15326
15327 case 3: //Stalfos 2
15328 if(tempguy->misc1==1) // Fires four projectiles at once
15329 tempguy->misc1=e1t4SHOTS;
15330 else tempguy->misc1 = 0;
15331
15332 break;
15333
15334 case 4: //Darknut 5
15335 darknuts:
15336 tempguy->defense[edefFIRE] = edIGNORE;
15337 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15338 tempguy->defense[edefHOOKSHOT] = 0;
15339 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15340 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15341
15342 if(tempguy->misc1==1)
15343 tempguy->misc1=2;
15344 else if(tempguy->misc1==2)
15345 {
15346 tempguy->misc4=tempguy->misc3;
15347 tempguy->misc3=tempguy->misc2;
15348 tempguy->misc2=e2tSPLIT;
15349 tempguy->misc1 = 0;
15350 }
15351 else tempguy->misc1 = 0;
15352
15353 tempguy->flags |= inv_front;
15354
15355 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15356 tempguy->flags |= guy_bkshield;
15357
15358 break;
15359 }
15360
15361 tempguy->misc10 = 0;
15362 break;
15363
15364 /*
15365 case 9: //eeARMOS
15366 tempguy->family = eeWALK;
15367 break;
15368 */
15369 case 11: //eeGEL
15370 case 33: //eeGELTRIB
15371 if(tempguy->family==33)
15372 {
15373 tempguy->misc4 = 1;
15374
15375 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15376 tempguy->misc3 = tempguy->misc2;
15377
15378 tempguy->misc2 = e2tTRIBBLE;
15379 }
15380 else
15381 {
15382 tempguy->misc4 = 0;
15383 tempguy->misc3 = 0;
15384 tempguy->misc2 = 0;
15385 }
15386
15387 tempguy->family = eeWALK;
15388
15389 if(tempguy->misc1)
15390 {
15391 tempguy->misc1=1;
15392 tempguy->weapon = ewFireTrail;
15393 }
15394
15395 break;
15396
15397 case 34: //eeZOLTRIB
15398 case 12: //eeZOL
15399 tempguy->misc4=tempguy->misc3;
15400 tempguy->misc3=tempguy->misc2;
15401 tempguy->family = eeWALK;
15402 tempguy->misc2=e2tSPLITHIT;
15403
15404 if(tempguy->misc1)
15405 {
15406 tempguy->misc1=1;
15407 tempguy->weapon = ewFireTrail;
15408 }
15409
15410 break;
15411
15412 case 13: //eeROPE
15413 tempguy->family = eeWALK;
15414 tempguy->misc9 = e9tROPE;
15415
15416 if(tempguy->misc1)
15417 {
15418 tempguy->misc4 = tempguy->misc3;
15419 tempguy->misc3 = tempguy->misc2;
15420 tempguy->misc2 = e2tBOMBCHU;
15421 }
15422
15423 tempguy->misc1 = 0;
15424 break;
15425
15426 case 14: //eeGORIYA
15427 tempguy->family = eeWALK;
15428
15429 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15430
15431 break;
15432
15433 case 17: //eeBUBBLE
15434 tempguy->family = eeWALK;
15435 tempguy->misc8 = tempguy->misc2;
15436 tempguy->misc7 = tempguy->misc1 + 1;
15437 tempguy->misc1 = tempguy->misc2 = 0;
15438
15439 //fallthrogh
15440 case eeTRAP:
15441 case eeROCK:
15442 doesntcount = true;
15443 break;
15444
15445 case 35: //eeVIRETRIB
15446 case 18: //eeVIRE
15447 tempguy->family = eeWALK;
15448 tempguy->misc4=tempguy->misc3;
15449 tempguy->misc3=tempguy->misc2;
15450 tempguy->misc2=e2tSPLITHIT;
15451 tempguy->misc9=e9tVIRE;
15452 break;
15453
15454 case 19: //eeLIKE
15455 tempguy->family = eeWALK;
15456 tempguy->misc7 = e7tEATITEMS;
15457 tempguy->misc8=95;
15458 break;
15459
15460 case 20: //eePOLSV
15461 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15462 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15463 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15464 tempguy->defense[edefARROW] = ed1HKO;
15465 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15466 tempguy->family = eeWALK;
15467 tempguy->misc9 = e9tPOLSVOICE;
15468 tempguy->rate = 4;
15469 tempguy->homing = 32;
15470 tempguy->hrate = 10;
15471 tempguy->grumble = 0;
15472 break;
15473
15474 case eeWIZZ:
15475 if(tempguy->misc4)
15476 {
15477 for(int32_t i=0; i < edefLAST; i++)
15478 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15479 }
15480 else
15481 {
15482 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15483 tempguy->defense[edefMAGIC] = edCHINK;
15484 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15485 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15486 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15487 }
15488
15489 break;
15490
15491 case eePEAHAT:
15492 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15493
15494 if(!(tempguy->flags & guy_bhit))
15495 tempguy->defense[edefBRANG] = edSTUNONLY;
15496
15497 break;
15498
15499 case eeLEV:
15500 tempguy->defense[edefSTOMP] = edCHINK;
15501 break;
15502 }
15503
15504 // Old flags
15505 if(tempguy->flags & guy_superman)
15506 {
15507 for(int32_t i = 0; i < edefLAST; i++)
15508 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15509 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15510 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15511 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15512 }
15513
15514 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15515
15516 if(doesntcount)
15517 tempguy->flags |= (guy_doesntcount);
15518 }
15519
15520
15521 31416 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15522 {
15523 byte tempbyte, padding;
15524 int32_t extras, secretcombos;
15525 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->valid),f,true))
15527 {
15528 return qe_invalid;
15529 }
15530
15531
15532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->guy),f,true))
15533 {
15534 return qe_invalid;
15535 }
15536
15537
2/6
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15538 {
15539 if(!p_getc(&tempbyte,f,true))
15540 {
15541 return qe_invalid;
15542 }
15543
15544 temp_mapscr->str=tempbyte;
15545 }
15546 else
15547 {
15548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_igetw(&(temp_mapscr->str),f,true))
15549 {
15550 return qe_invalid;
15551 }
15552 }
15553
15554
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->room),f,true))
15555 {
15556 return qe_invalid;
15557 }
15558
15559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->item),f,true))
15560 {
15561 return qe_invalid;
15562 }
15563
15564
2/6
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15565 {
15566 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15567 }
15568 else
15569 {
15570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15571 return qe_invalid;
15572 }
15573
15574
1/4
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 if((Header->zelda_version < 0x192)||
15575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15576 {
15577 if(!p_getc(&tempbyte,f,true))
15578 {
15579 return qe_invalid;
15580 }
15581 }
15582
15583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15584 {
15585 return qe_invalid;
15586 }
15587
15588
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(Header->zelda_version < 0x193)
15589 {
15590 if(!p_getc(&tempbyte,f,true))
15591 {
15592 return qe_invalid;
15593 }
15594 }
15595
15596
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15597 {
15598
2/2
✓ Branch 0 taken 94248 times.
✓ Branch 1 taken 31416 times.
125664 for(int32_t i=1; i<4; i++)
15599 {
15600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94248 times.
94248 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15601 {
15602 return qe_invalid;
15603 }
15604 94248 }
15605 31416 }
15606 else
15607 {
15608 temp_mapscr->tilewarptype[1]=0;
15609 temp_mapscr->tilewarptype[2]=0;
15610 temp_mapscr->tilewarptype[3]=0;
15611 }
15612
15613
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15614 {
15615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15616 {
15617 return qe_invalid;
15618 }
15619 31416 }
15620
15621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15622 {
15623 return qe_invalid;
15624 }
15625
15626 31416 temp_mapscr->warpreturnx[1]=0;
15627 31416 temp_mapscr->warpreturnx[2]=0;
15628 31416 temp_mapscr->warpreturnx[3]=0;
15629
15630
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15631 {
15632
2/2
✓ Branch 0 taken 94248 times.
✓ Branch 1 taken 31416 times.
125664 for(int32_t i=1; i<4; i++)
15633 {
15634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94248 times.
94248 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15635 {
15636 return qe_invalid;
15637 }
15638 94248 }
15639 31416 }
15640
15641
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15642 {
15643 return qe_invalid;
15644 }
15645
15646 31416 temp_mapscr->warpreturny[1]=0;
15647 31416 temp_mapscr->warpreturny[2]=0;
15648 31416 temp_mapscr->warpreturny[3]=0;
15649
15650
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15651 {
15652
2/2
✓ Branch 0 taken 94248 times.
✓ Branch 1 taken 31416 times.
125664 for(int32_t i=1; i<4; i++)
15653 {
15654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94248 times.
94248 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15655 {
15656 return qe_invalid;
15657 }
15658 94248 }
15659
15660
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(version>=18)
15661 {
15662
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15663 {
15664 return qe_invalid;
15665 }
15666 31416 }
15667 else
15668 {
15669 byte temp;
15670
15671 if(!p_getc(&temp,f,true))
15672 {
15673 return qe_invalid;
15674 }
15675
15676 temp_mapscr->warpreturnc=temp<<8|temp;
15677 }
15678 31416 }
15679
15680
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->stairx),f,true))
15681
15682 {
15683 return qe_invalid;
15684 }
15685
15686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->stairy),f,true))
15687 {
15688 return qe_invalid;
15689 }
15690
15691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->itemx),f,true))
15692 {
15693 return qe_invalid;
15694 }
15695
15696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->itemy),f,true))
15697 {
15698 return qe_invalid;
15699 }
15700
15701
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(version > 15) // February 2009
15702 {
15703
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_igetw(&(temp_mapscr->color),f,true))
15704 {
15705 return qe_invalid;
15706 }
15707 31416 }
15708 else
15709 {
15710 if(!p_getc(& tempbyte,f,true))
15711 {
15712 return qe_invalid;
15713 }
15714
15715 temp_mapscr->color = (word) tempbyte;
15716 }
15717
15718
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15719 {
15720 return qe_invalid;
15721 }
15722
15723
2/2
✓ Branch 0 taken 125664 times.
✓ Branch 1 taken 31416 times.
157080 for(int32_t k=0; k<4; k++)
15724 {
15725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125664 times.
125664 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15726 {
15727 return qe_invalid;
15728
15729 }
15730 125664 }
15731
15732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(version <= 11)
15733 {
15734 if(!p_getc(&(tempbyte),f,true))
15735 {
15736 return qe_invalid;
15737 }
15738
15739 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15740
15741 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15742 {
15743 for(int32_t i=1; i<4; i++)
15744 {
15745 if(!p_getc(&(tempbyte),f,true))
15746 {
15747 return qe_invalid;
15748 }
15749
15750 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15751 }
15752 }
15753 else
15754 {
15755 temp_mapscr->tilewarpdmap[1]=0;
15756 temp_mapscr->tilewarpdmap[2]=0;
15757 temp_mapscr->tilewarpdmap[3]=0;
15758 }
15759 }
15760 else
15761 {
15762
2/2
✓ Branch 0 taken 125664 times.
✓ Branch 1 taken 31416 times.
157080 for(int32_t i=0; i<4; i++)
15763 {
15764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125664 times.
125664 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15765 {
15766 return qe_invalid;
15767 }
15768 125664 }
15769 }
15770
15771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15772 {
15773 return qe_invalid;
15774 }
15775
15776
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15777 {
15778
2/2
✓ Branch 0 taken 94248 times.
✓ Branch 1 taken 31416 times.
125664 for(int32_t i=1; i<4; i++)
15779 {
15780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94248 times.
94248 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15781 {
15782 return qe_invalid;
15783 }
15784 94248 }
15785 31416 }
15786 else
15787 {
15788 temp_mapscr->tilewarpscr[1]=0;
15789 temp_mapscr->tilewarpscr[2]=0;
15790 temp_mapscr->tilewarpscr[3]=0;
15791 }
15792
15793
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(version >= 15)
15794 {
15795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15796 {
15797 return qe_invalid;
15798 }
15799 31416 }
15800 else
15801 {
15802 temp_mapscr->tilewarpoverlayflags=0;
15803 }
15804
15805
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15806 {
15807 return qe_invalid;
15808 }
15809
15810
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(Header->zelda_version < 0x193)
15811 {
15812 if(!p_getc(&tempbyte,f,true))
15813 {
15814 return qe_invalid;
15815 }
15816
15817 }
15818
15819
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15820 {
15821 if(!p_getc(&padding,f,true))
15822 {
15823 return qe_invalid;
15824 }
15825 }
15826
15827
2/2
✓ Branch 0 taken 314160 times.
✓ Branch 1 taken 31416 times.
345576 for(int32_t k=0; k<10; k++)
15828 {
15829 /*
15830 if (!temp_mapscr->enemy[k])
15831 {
15832 continue;
15833 }
15834 */
15835
2/6
✓ Branch 0 taken 314160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 314160 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
314160 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15836 {
15837 if(!p_getc(&tempbyte,f,true))
15838 {
15839 return qe_invalid;
15840 }
15841
15842 temp_mapscr->enemy[k]=tempbyte;
15843 }
15844 else
15845 {
15846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314160 times.
314160 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
15847 {
15848 return qe_invalid;
15849 }
15850 }
15851
15852
2/6
✓ Branch 0 taken 314160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 314160 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
314160 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15853 {
15854 //using enumerations here is dangerous
15855 //very easy to break old quests -DD
15856 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15857 {
15858 temp_mapscr->enemy[k]+=5;
15859 }
15860 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15861 {
15862 temp_mapscr->enemy[k]+=1;
15863 }
15864 }
15865
15866
1/2
✓ Branch 0 taken 314160 times.
✗ Branch 1 not taken.
314160 if(version < 9)
15867 {
15868 if(temp_mapscr->enemy[k]>0)
15869 {
15870 temp_mapscr->enemy[k]+=10;
15871 }
15872 }
15873 //don't read in any invalid data
15874
1/2
✓ Branch 0 taken 314160 times.
✗ Branch 1 not taken.
314160 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15875 {
15876 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15877 temp_mapscr->enemy[k] = 0;
15878 }
15879 314160 }
15880
15881
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->pattern),f,true))
15882 {
15883 return qe_invalid;
15884 }
15885
15886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
15887 {
15888 return qe_invalid;
15889 }
15890
15891
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15892 {
15893
2/2
✓ Branch 0 taken 94248 times.
✓ Branch 1 taken 31416 times.
125664 for(int32_t i=1; i<4; i++)
15894 {
15895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94248 times.
94248 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
15896 {
15897 return qe_invalid;
15898 }
15899 94248 }
15900 31416 }
15901 else
15902 {
15903 temp_mapscr->sidewarptype[1]=0;
15904 temp_mapscr->sidewarptype[2]=0;
15905 temp_mapscr->sidewarptype[3]=0;
15906 }
15907
15908
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(version >= 15)
15909 {
15910
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
15911 {
15912 return qe_invalid;
15913 }
15914 31416 }
15915 else
15916 {
15917 temp_mapscr->sidewarpoverlayflags=0;
15918 }
15919
15920
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
15921 {
15922 return qe_invalid;
15923 }
15924
15925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
15926 {
15927 return qe_invalid;
15928 }
15929
15930
2/2
✓ Branch 0 taken 125664 times.
✓ Branch 1 taken 31416 times.
157080 for(int32_t k=0; k<4; k++)
15931 {
15932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125664 times.
125664 if(!p_getc(&(temp_mapscr->path[k]),f,true))
15933 {
15934 return qe_invalid;
15935 }
15936 125664 }
15937
15938
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
15939 {
15940 return qe_invalid;
15941 }
15942
15943
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15944 {
15945
2/2
✓ Branch 0 taken 31416 times.
✓ Branch 1 taken 94248 times.
125664 for(int32_t i=1; i<4; i++)
15946 {
15947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94248 times.
94248 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
15948 {
15949 return qe_invalid;
15950 }
15951 94248 }
15952 31416 }
15953 else
15954 {
15955 temp_mapscr->sidewarpscr[1]=0;
15956 temp_mapscr->sidewarpscr[2]=0;
15957 temp_mapscr->sidewarpscr[3]=0;
15958 }
15959
15960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(version <= 11)
15961 {
15962 if(!p_getc(&(tempbyte),f,true))
15963 {
15964 return qe_invalid;
15965 }
15966
15967 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15968
15969 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15970 {
15971 for(int32_t i=1; i<4; i++)
15972 {
15973 if(!p_getc(&(tempbyte),f,true))
15974 {
15975 return qe_invalid;
15976 }
15977
15978 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15979 }
15980 }
15981 else
15982 {
15983 temp_mapscr->sidewarpdmap[1]=0;
15984 temp_mapscr->sidewarpdmap[2]=0;
15985 temp_mapscr->sidewarpdmap[3]=0;
15986 }
15987 }
15988 else
15989 {
15990
2/2
✓ Branch 0 taken 125664 times.
✓ Branch 1 taken 31416 times.
157080 for(int32_t i=0; i<4; i++)
15991 {
15992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125664 times.
125664 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
15993 {
15994 return qe_invalid;
15995 }
15996 125664 }
15997 }
15998
15999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16000 {
16001
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16002 {
16003 return qe_invalid;
16004 }
16005 31416 }
16006 else temp_mapscr->sidewarpindex = 0;
16007
16008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16009 {
16010 return qe_invalid;
16011 }
16012
16013
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(Header->zelda_version < 0x193)
16014 {
16015 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16016 {
16017 return qe_invalid;
16018 }
16019 }
16020
16021
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16022 {
16023 return qe_invalid;
16024 }
16025
16026
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16027 {
16028 return qe_invalid;
16029 }
16030
16031
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->flags),f,true))
16032 {
16033 return qe_invalid;
16034 }
16035
16036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->flags2),f,true))
16037 {
16038 return qe_invalid;
16039 }
16040
16041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->flags3),f,true))
16042 {
16043 return qe_invalid;
16044 }
16045
16046
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16047 //if (version>2)
16048 {
16049
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->flags4),f,true))
16050 {
16051 return qe_invalid;
16052 }
16053 31416 }
16054
16055
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16056 {
16057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->flags5),f,true))
16058 {
16059 return qe_invalid;
16060 }
16061
16062
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16063 {
16064 return qe_invalid;
16065 }
16066
16067
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16068 {
16069 return qe_invalid;
16070 }
16071
16072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(temp_mapscr->flags5&32)
16073 {
16074 temp_mapscr->flags5 &= ~32;
16075 temp_mapscr->noreset |= 48;
16076 }
16077
16078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(version<8)
16079 {
16080 if(temp_mapscr->noreset&1)
16081 {
16082 temp_mapscr->noreset|=8192;
16083 }
16084
16085 if(temp_mapscr->nocarry&1)
16086 {
16087 temp_mapscr->nocarry|=8192;
16088 temp_mapscr->nocarry&=~1;
16089 }
16090 }
16091 31416 }
16092 else
16093 {
16094 temp_mapscr->flags5 = 0;
16095 temp_mapscr->noreset = 0;
16096 temp_mapscr->nocarry = 0;
16097 }
16098
16099
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16100 {
16101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->flags6),f,true))
16102 {
16103 return qe_invalid;
16104 }
16105 31416 }
16106
16107
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(version>5)
16108 {
16109
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->flags7),f,true))
16110 {
16111 return qe_invalid;
16112 }
16113
16114
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->flags8),f,true))
16115 {
16116 return qe_invalid;
16117 }
16118
16119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->flags9),f,true))
16120 {
16121 return qe_invalid;
16122 }
16123
16124
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->flags10),f,true))
16125 {
16126 return qe_invalid;
16127 }
16128
16129
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16130 {
16131 return qe_invalid;
16132 }
16133 31416 }
16134 else
16135 {
16136 temp_mapscr->csensitive=1;
16137 }
16138
16139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(version<14) // August 2007: screen SFX added
16140 {
16141 if(temp_mapscr->flags&8) //fROAR
16142 {
16143 temp_mapscr->bosssfx=
16144 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16145 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16146 WAV_ROAR;
16147 }
16148
16149 if(temp_mapscr->flags&128) //fSEA
16150 {
16151 temp_mapscr->oceansfx=WAV_SEA;
16152 }
16153
16154 if(!(temp_mapscr->flags3&64)) //fNOSECRETSOUND
16155 {
16156 temp_mapscr->secretsfx=WAV_SECRET;
16157 }
16158
16159 temp_mapscr->flags3 &= ~66; //64|2
16160 temp_mapscr->flags2 &= ~32;
16161 temp_mapscr->flags &= ~136; // 128|8
16162 }
16163 else
16164 {
16165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16166 {
16167 return qe_invalid;
16168 }
16169
16170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16171 {
16172 return qe_invalid;
16173 }
16174
16175
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16176 {
16177 return qe_invalid;
16178 }
16179 }
16180
16181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(version<15) // October 2007: another SFX
16182 {
16183 temp_mapscr->holdupsfx=WAV_PICKUP;
16184 }
16185 else
16186 {
16187
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16188 {
16189 return qe_invalid;
16190 }
16191 }
16192
16193
16194
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16195 {
16196
2/2
✓ Branch 0 taken 188496 times.
✓ Branch 1 taken 31416 times.
219912 for(int32_t k=0; k<6; k++)
16197 {
16198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188496 times.
188496 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16199 {
16200 return qe_invalid;
16201 }
16202 188496 }
16203
16204
2/2
✓ Branch 0 taken 31416 times.
✓ Branch 1 taken 188496 times.
219912 for(int32_t k=0; k<6; k++)
16205 {
16206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188496 times.
188496 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16207 {
16208 return qe_invalid;
16209 }
16210 188496 }
16211 31416 }
16212 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16213 {
16214 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16215 {
16216 return qe_invalid;
16217 }
16218
16219 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16220 {
16221 return qe_invalid;
16222 }
16223
16224 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16225 {
16226 return qe_invalid;
16227 }
16228
16229 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16230
16231 {
16232 return qe_invalid;
16233 }
16234 }
16235
16236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 if((Header->zelda_version == 0x192)&&(Header->build>149))
16237 {
16238 for(int32_t k=0; k<6; k++)
16239 {
16240 if(!p_getc(&tempbyte,f,true)) //layerxsize
16241 {
16242 return qe_invalid;
16243 }
16244 }
16245
16246 for(int32_t k=0; k<6; k++)
16247 {
16248 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16249 {
16250 return qe_invalid;
16251 }
16252 }
16253
16254 for(int32_t k=0; k<6; k++)
16255 {
16256 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16257 {
16258 return qe_invalid;
16259 }
16260 }
16261
16262 for(int32_t k=0; k<6; k++)
16263 {
16264 if(!p_getc(&tempbyte,f,true)) //layerysize
16265 {
16266 return qe_invalid;
16267 }
16268 }
16269
16270 for(int32_t k=0; k<6; k++)
16271 {
16272 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16273 {
16274 return qe_invalid;
16275 }
16276 }
16277
16278 for(int32_t k=0; k<6; k++)
16279 {
16280 if(!p_getc(&tempbyte,f,true)) //layerydelay
16281 {
16282 return qe_invalid;
16283 }
16284 }
16285 }
16286
16287
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16288 {
16289
2/2
✓ Branch 0 taken 188496 times.
✓ Branch 1 taken 31416 times.
219912 for(int32_t k=0; k<6; k++)
16290 {
16291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188496 times.
188496 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16292 {
16293 return qe_invalid;
16294 }
16295 188496 }
16296 31416 }
16297
16298
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16299 {
16300
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 if((Header->zelda_version == 0x192)&&(Header->build>153))
16301 {
16302 if(!p_getc(&padding,f,true))
16303 {
16304 return qe_invalid;
16305 }
16306 }
16307
16308
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16309 {
16310 return qe_invalid;
16311 }
16312 31416 }
16313
16314
2/6
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16315 {
16316 extras=15;
16317 }
16318
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16319 {
16320 extras=11;
16321 }
16322
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16323 {
16324 extras=32;
16325 }
16326
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16327 {
16328 extras=64;
16329 }
16330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 else if(Header->zelda_version < 0x193)
16331 {
16332 extras=62;
16333 }
16334 else
16335
16336 {
16337 31416 extras=0;
16338 }
16339
16340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 for(int32_t k=0; k<extras; k++)
16341 {
16342 if(!p_getc(&tempbyte,f,true)) //extra[k]
16343 {
16344 return qe_invalid;
16345 }
16346 }
16347
16348
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16349 //if (version>3)
16350 {
16351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16352 {
16353 return qe_invalid;
16354 }
16355
16356
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16357 {
16358 return qe_invalid;
16359 }
16360 31416 }
16361 else
16362 {
16363 temp_mapscr->nextmap=0;
16364 temp_mapscr->nextscr=0;
16365 }
16366
16367
2/6
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16368 {
16369 secretcombos=20;
16370 }
16371
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16372 {
16373 secretcombos=256;
16374 }
16375 else
16376 {
16377 31416 secretcombos=128;
16378 }
16379
16380
2/6
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16381 {
16382 for(int32_t k=0; k<secretcombos; k++)
16383 {
16384 if(!p_getc(&tempbyte,f,true))
16385 {
16386 return qe_invalid;
16387 }
16388
16389 if(k<128)
16390 {
16391 temp_mapscr->secretcombo[k]=tempbyte;
16392 }
16393 }
16394 }
16395 else
16396 {
16397
2/2
✓ Branch 0 taken 4021248 times.
✓ Branch 1 taken 31416 times.
4052664 for(int32_t k=0; k<128; k++)
16398 {
16399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4021248 times.
4021248 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16400 {
16401 return qe_invalid;
16402 }
16403
16404 4021248 }
16405 }
16406
16407
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16408 {
16409
2/2
✓ Branch 0 taken 4021248 times.
✓ Branch 1 taken 31416 times.
4052664 for(int32_t k=0; k<128; k++)
16410 {
16411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4021248 times.
4021248 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16412 {
16413 return qe_invalid;
16414 }
16415 4021248 }
16416
16417
2/2
✓ Branch 0 taken 4021248 times.
✓ Branch 1 taken 31416 times.
4052664 for(int32_t k=0; k<128; k++)
16418 {
16419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4021248 times.
4021248 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16420 {
16421 return qe_invalid;
16422 }
16423 4021248 }
16424 31416 }
16425
16426
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16427 {
16428 if(!p_getc(&padding,f,true))
16429 {
16430 return qe_invalid;
16431 }
16432 }
16433
16434 31416 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16435
16436
2/2
✓ Branch 0 taken 5529216 times.
✓ Branch 1 taken 31416 times.
5560632 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16437 {
16438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5529216 times.
5529216 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16439 {
16440 return qe_invalid;
16441 }
16442 5529216 }
16443
16444
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16445 {
16446 if(!p_getc(&padding,f,true))
16447 {
16448 return qe_invalid;
16449 }
16450
16451 if(!p_getc(&padding,f,true))
16452 {
16453 return qe_invalid;
16454 }
16455 }
16456
16457
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16458 {
16459
2/2
✓ Branch 0 taken 5529216 times.
✓ Branch 1 taken 31416 times.
5560632 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16460 {
16461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5529216 times.
5529216 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16462 {
16463 return qe_invalid;
16464 }
16465
16466
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5529216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5529216 if((Header->zelda_version == 0x192)&&(Header->build<24))
16467 {
16468 if(!p_getc(&tempbyte,f,true))
16469 {
16470 return qe_invalid;
16471 }
16472
16473 if(!p_getc(&tempbyte,f,true))
16474 {
16475 return qe_invalid;
16476 }
16477
16478 if(!p_getc(&tempbyte,f,true))
16479 {
16480 return qe_invalid;
16481 }
16482 }
16483 5529216 }
16484 31416 }
16485
16486
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16487 {
16488
2/2
✓ Branch 0 taken 31416 times.
✓ Branch 1 taken 5529216 times.
5560632 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16489 {
16490
16491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5529216 times.
5529216 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16492 {
16493 return qe_invalid;
16494 }
16495 5529216 }
16496 31416 }
16497
16498
2/6
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16499 {
16500 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16501 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16502 }
16503
16504
2/6
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16505 {
16506 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16507 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16508 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16509 temp_mapscr->secretcombo[sDINSFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16510 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16511 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16512 }
16513
16514
2/6
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31416 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16515 {
16516 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16517 {
16518 if((Header->zelda_version == 0x192)&&(Header->build>149))
16519 {
16520 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16521 {
16522 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16523 }
16524 }
16525 else
16526 {
16527 if((Header->zelda_version < 0x192)||
16528 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16529 {
16530 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16531 }
16532
16533 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16534 }
16535
16536 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16537 }
16538 }
16539
16540 /*if(version>12)
16541 {
16542 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16543 {
16544 return qe_invalid;
16545 }
16546 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16547 {
16548 return qe_invalid;
16549 }
16550 }*/
16551
16552
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(version>4)
16553 {
16554
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16555 {
16556 return qe_invalid;
16557 }
16558 31416 }
16559 else
16560 {
16561 temp_mapscr->screen_midi = -1;
16562 }
16563
16564
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(version>=17)
16565 {
16566
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16567 {
16568 return qe_invalid;
16569 }
16570 31416 }
16571 else
16572 {
16573 temp_mapscr->lens_layer = llNORMAL;
16574 }
16575
16576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(version>6)
16577 {
16578 dword bits;
16579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if(!p_igetl(&bits,f,true))
16580 {
16581 return qe_invalid;
16582 }
16583
16584 int32_t m;
16585 float tempfloat;
16586 word tempw;
16587
16588
2/2
✓ Branch 0 taken 31416 times.
✓ Branch 1 taken 1005312 times.
1036728 for(m=0; m<32; m++)
16589 {
16590 1005312 ffcdata& tempffc = temp_mapscr->ffcs[m];
16591 1005312 tempffc.clear();
16592
2/2
✓ Branch 0 taken 1003044 times.
✓ Branch 1 taken 2268 times.
1005312 if((bits>>m)&1)
16593 {
16594
1/2
✓ Branch 0 taken 2268 times.
✗ Branch 1 not taken.
2268 if(!p_igetw(&tempw,f,true))
16595 {
16596 return qe_invalid;
16597 }
16598 2268 tempffc.setData(tempw);
16599
16600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_getc(&(tempffc.cset),f,true))
16601 {
16602 return qe_invalid;
16603 }
16604
16605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetw(&(tempffc.delay),f,true))
16606 {
16607 return qe_invalid;
16608 }
16609
16610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(version < 9)
16611 {
16612 if(!p_igetf(&tempfloat,f,true))
16613 {
16614 return qe_invalid;
16615 }
16616
16617 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16618
16619 if(!p_igetf(&tempfloat,f,true))
16620 {
16621 return qe_invalid;
16622 }
16623
16624 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16625
16626 if(!p_igetf(&tempfloat,f,true))
16627 {
16628 return qe_invalid;
16629 }
16630
16631 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16632
16633 if(!p_igetf(&tempfloat,f,true))
16634 {
16635 return qe_invalid;
16636 }
16637
16638 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16639
16640 if(!p_igetf(&tempfloat,f,true))
16641 {
16642 return qe_invalid;
16643 }
16644
16645 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16646
16647 if(!p_igetf(&tempfloat,f,true))
16648 {
16649 return qe_invalid;
16650 }
16651
16652 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16653 }
16654 else
16655 {
16656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetzf(&(tempffc.x),f,true))
16657 {
16658 return qe_invalid;
16659 }
16660
16661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetzf(&(tempffc.y),f,true))
16662 {
16663 return qe_invalid;
16664 }
16665
16666
1/2
✓ Branch 0 taken 2268 times.
✗ Branch 1 not taken.
2268 if(!p_igetzf(&(tempffc.vx),f,true))
16667 {
16668 return qe_invalid;
16669 }
16670
16671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetzf(&(tempffc.vy),f,true))
16672 {
16673 return qe_invalid;
16674 }
16675
16676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetzf(&(tempffc.ax),f,true))
16677 {
16678 return qe_invalid;
16679 }
16680
16681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetzf(&(tempffc.ay),f,true))
16682 {
16683 return qe_invalid;
16684 }
16685 }
16686
16687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_getc(&(tempffc.link),f,true))
16688 {
16689 return qe_invalid;
16690 }
16691
16692
1/2
✓ Branch 0 taken 2268 times.
✗ Branch 1 not taken.
2268 if(version>7)
16693 {
16694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_getc(&tempbyte,f,true))
16695 {
16696 return qe_invalid;
16697 }
16698
16699 2268 tempffc.hxsz = (tempbyte&0x3F)+1;
16700 2268 tempffc.txsz = (tempbyte>>6)+1;
16701
16702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_getc(&tempbyte,f,true))
16703 {
16704 return qe_invalid;
16705 }
16706
16707 2268 tempffc.hysz = (tempbyte&0x3F)+1;
16708 2268 tempffc.tysz = (tempbyte>>6)+1;
16709
16710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetl(&(tempffc.flags),f,true))
16711 {
16712 return qe_invalid;
16713 }
16714 2268 }
16715 else
16716 {
16717 tempffc.hxsz=16;
16718 tempffc.hysz=16;
16719 tempffc.txsz=1;
16720 tempffc.tysz=1;
16721 tempffc.flags=0;
16722 }
16723
16724 2268 tempffc.updateSolid();
16725
16726
16727
3/6
✓ Branch 0 taken 2268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2268 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2268 times.
2268 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16728 {
16729 tempffc.flags|=ffIGNOREHOLDUP;
16730 }
16731
16732
1/2
✓ Branch 0 taken 2268 times.
✗ Branch 1 not taken.
2268 if(version>9)
16733 {
16734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetw(&(tempffc.script),f,true))
16735 {
16736 return qe_invalid;
16737 }
16738 2268 }
16739 else
16740 {
16741 tempffc.script=0;
16742 }
16743
16744
1/2
✓ Branch 0 taken 2268 times.
✗ Branch 1 not taken.
2268 if(version>10)
16745 {
16746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetl(&(tempffc.initd[0]),f,true))
16747 {
16748 return qe_invalid;
16749 }
16750
16751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetl(&(tempffc.initd[1]),f,true))
16752 {
16753 return qe_invalid;
16754 }
16755
16756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetl(&(tempffc.initd[2]),f,true))
16757 {
16758 return qe_invalid;
16759 }
16760
16761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetl(&(tempffc.initd[3]),f,true))
16762 {
16763 return qe_invalid;
16764 }
16765
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetl(&(tempffc.initd[4]),f,true))
16767 {
16768 return qe_invalid;
16769 }
16770
16771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetl(&(tempffc.initd[5]),f,true))
16772 {
16773 return qe_invalid;
16774 }
16775
16776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetl(&(tempffc.initd[6]),f,true))
16777 {
16778 return qe_invalid;
16779 }
16780
16781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_igetl(&(tempffc.initd[7]),f,true))
16782 {
16783 return qe_invalid;
16784 }
16785
16786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_getc(&(tempbyte),f,true))
16787 {
16788 return qe_invalid;
16789 }
16790
16791 2268 tempffc.inita[0]=tempbyte*10000;
16792
16793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2268 times.
2268 if(!p_getc(&(tempbyte),f,true))
16794 {
16795 return qe_invalid;
16796 }
16797
16798 2268 tempffc.inita[1]=tempbyte*10000;
16799 2268 }
16800 else
16801 {
16802 tempffc.inita[0] = 10000;
16803 tempffc.inita[1] = 10000;
16804 }
16805
16806 2268 tempffc.initialized = false;
16807
16808
1/2
✓ Branch 0 taken 2268 times.
✗ Branch 1 not taken.
2268 if(version <= 11)
16809 {
16810 fixffcs=true;
16811 }
16812 2268 }
16813 1005312 }
16814
16815 31416 }
16816
16817 //add in the new whistle flags
16818
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(version<13)
16819 {
16820 if(temp_mapscr->flags & fWHISTLE)
16821 {
16822 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16823 }
16824 }
16825
16826 // for(int32_t m=0; m<32; m++)
16827 // {
16828 // // ffcScriptData used to be part of mapscr, and this was handled just above
16829 // ffcScriptData[m].a[0] = 10000;
16830 // ffcScriptData[m].a[1] = 10000;
16831 // }
16832
16833 //2.55 starts here
16834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 if ( version >= 19 && Header->zelda_version > 0x253 )
16835 {
16836 for ( int32_t q = 0; q < 10; q++ )
16837 {
16838 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
16839 {
16840 return qe_invalid;
16841 }
16842 }
16843 for ( int32_t q = 0; q < 10; q++ )
16844 {
16845 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
16846 {
16847 return qe_invalid;
16848 }
16849 }
16850 for ( int32_t q = 0; q < 10; q++ )
16851 {
16852 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
16853 {
16854 return qe_invalid;
16855 }
16856 }
16857 for ( int32_t q = 0; q < 10; q++ )
16858 {
16859 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
16860 {
16861 return qe_invalid;
16862 }
16863 }
16864 }
16865
2/4
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31416 times.
31416 if ( version < 19 && Header->zelda_version > 0x253 )
16866 {
16867 for ( int32_t q = 0; q < 10; q++ )
16868 {
16869 temp_mapscr->npcstrings[q] = 0;
16870 temp_mapscr->new_items[q] = 0;
16871 temp_mapscr->new_item_x[q] = 0;
16872 temp_mapscr->new_item_y[q] = 0;
16873 }
16874 }
16875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 if ( version >= 20 && Header->zelda_version > 0x253 )
16876 {
16877 if(!p_igetw(&(temp_mapscr->script),f,true))
16878 {
16879 return qe_invalid;
16880 }
16881 for ( int32_t q = 0; q < 8; q++)
16882 {
16883 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
16884 {
16885 return qe_invalid;
16886 }
16887 }
16888 }
16889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
31416 if ( version < 20 )
16890 {
16891 31416 temp_mapscr->script = 0;
16892
2/2
✓ Branch 0 taken 251328 times.
✓ Branch 1 taken 31416 times.
282744 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16893 31416 }
16894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 if ( version >= 21 && Header->zelda_version > 0x253 )
16895 {
16896 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
16897 {
16898 return qe_invalid;
16899 }
16900 }
16901
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if ( version < 21 )
16902 {
16903 31416 temp_mapscr->preloadscript = 0;
16904 31416 }
16905 //all builds with version > 20 need this. -Z
16906 31416 temp_mapscr->ffcswaitdraw = 0;
16907
16908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31416 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16909 {
16910 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
16911 {
16912 return qe_invalid;
16913 }
16914 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
16915 {
16916 return qe_invalid;
16917 }
16918 }
16919
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if ( version < 22 )
16920 {
16921 31416 temp_mapscr->hidelayers = 0;
16922 31416 temp_mapscr->hidescriptlayers = 0;
16923 31416 }
16924
16925 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16926 //May be any version before 2.11. -Z
16927 /* --not the roar, the HIT SFX
16928 if ( Header->zelda_version <= 0x210 )
16929 {
16930 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16931 {
16932 temp_mapscr->bosssfx = WAV_ROAR;
16933 }
16934 }
16935 */
16936
16937 31416 return 0;
16938 31416 }
16939 31688 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
16940 {
16941
2/2
✓ Branch 0 taken 31416 times.
✓ Branch 1 taken 272 times.
31688 if(version < 23)
16942 {
16943 31416 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16944
1/2
✓ Branch 0 taken 31416 times.
✗ Branch 1 not taken.
31416 if(ret) return ret;
16945 31416 temp_mapscr->update_ffc_count(31);
16946 31416 }
16947 else
16948 {
16949
1/2
✓ Branch 0 taken 272 times.
✗ Branch 1 not taken.
272 if(!p_getc(&(temp_mapscr->valid),f,true))
16950 return qe_invalid;
16951
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 261 times.
272 if(!(temp_mapscr->valid & mVALID))
16952 261 return 0; //Empty screen
16953 uint32_t scr_has_flags;
16954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!p_igetl(&scr_has_flags,f,true))
16955 return qe_invalid;
16956
16957
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_ROOMDATA)
16958 {
16959 if(!p_getc(&(temp_mapscr->guy),f,true))
16960 return qe_invalid;
16961 if(!p_igetw(&(temp_mapscr->str),f,true))
16962 return qe_invalid;
16963 if(!p_getc(&(temp_mapscr->room),f,true))
16964 return qe_invalid;
16965 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16966 return qe_invalid;
16967 }
16968
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_ITEM)
16969 {
16970 if(!p_getc(&(temp_mapscr->item),f,true))
16971 return qe_invalid;
16972 if(!p_getc(&(temp_mapscr->hasitem),f,true))
16973 return qe_invalid;
16974 if(!p_getc(&(temp_mapscr->itemx),f,true))
16975 return qe_invalid;
16976 if(!p_getc(&(temp_mapscr->itemy),f,true))
16977 return qe_invalid;
16978 }
16979
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16980 {
16981 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
16982 return qe_invalid;
16983 }
16984
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_TWARP)
16985 {
16986 for(int32_t i=0; i<4; i++)
16987 {
16988 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
16989 return qe_invalid;
16990 }
16991 for(int32_t i=0; i<4; i++)
16992 {
16993 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
16994 return qe_invalid;
16995 }
16996 for(int32_t i=0; i<4; i++)
16997 {
16998 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
16999 return qe_invalid;
17000 }
17001 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17002 return qe_invalid;
17003 }
17004
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_SWARP)
17005 {
17006 for(int32_t i=0; i<4; i++)
17007 {
17008 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17009 return qe_invalid;
17010 }
17011 for(int32_t i=0; i<4; i++)
17012 {
17013 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17014 return qe_invalid;
17015 }
17016 for(int32_t i=0; i<4; i++)
17017 {
17018 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17019 return qe_invalid;
17020 }
17021 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17022 return qe_invalid;
17023 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17024 return qe_invalid;
17025 }
17026
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_WARPRET)
17027 {
17028 for(int32_t i=0; i<4; i++)
17029 {
17030 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17031 return qe_invalid;
17032 }
17033 for(int32_t i=0; i<4; i++)
17034 {
17035 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17036 return qe_invalid;
17037 }
17038 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17039 return qe_invalid;
17040 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17041 return qe_invalid;
17042 }
17043
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
11 if(scr_has_flags & SCRHAS_LAYERS)
17044 {
17045
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2 times.
14 for(int32_t k=0; k<6; k++)
17046 {
17047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17048 return qe_invalid;
17049 12 }
17050
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2 times.
14 for(int32_t k=0; k<6; k++)
17051 {
17052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17053 return qe_invalid;
17054 12 }
17055
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2 times.
14 for(int32_t k=0; k<6; k++)
17056 {
17057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17058 return qe_invalid;
17059 12 }
17060
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17061 return qe_invalid;
17062
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17063 return qe_invalid;
17064 2 }
17065 else
17066 {
17067
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 9 times.
63 for(int32_t k=0; k<6; k++)
17068 {
17069 54 temp_mapscr->layeropacity[k] = 255;
17070 54 }
17071 }
17072
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_MAZE)
17073 {
17074 for(int32_t k=0; k<4; k++)
17075 {
17076 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17077 return qe_invalid;
17078 }
17079 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17080 return qe_invalid;
17081 }
17082
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4 times.
11 if(scr_has_flags & SCRHAS_D_S_U)
17083 {
17084
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17085 return qe_invalid;
17086
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t k=0; k<4; k++)
17087 {
17088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17089 return qe_invalid;
17090 16 }
17091
17092
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->stairx),f,true))
17093 return qe_invalid;
17094
17095
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->stairy),f,true))
17096 return qe_invalid;
17097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17098 return qe_invalid;
17099
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->undercset),f,true))
17100 return qe_invalid;
17101 4 }
17102
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
11 if(scr_has_flags & SCRHAS_FLAGS)
17103 {
17104
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->flags),f,true))
17105 return qe_invalid;
17106
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->flags2),f,true))
17107 return qe_invalid;
17108
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->flags3),f,true))
17109 return qe_invalid;
17110
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->flags4),f,true))
17111 return qe_invalid;
17112
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->flags5),f,true))
17113 return qe_invalid;
17114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!p_getc(&(temp_mapscr->flags6),f,true))
17115 return qe_invalid;
17116
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->flags7),f,true))
17117 return qe_invalid;
17118
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->flags8),f,true))
17119 return qe_invalid;
17120
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->flags9),f,true))
17121 return qe_invalid;
17122
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&(temp_mapscr->flags10),f,true))
17123 return qe_invalid;
17124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17125 return qe_invalid;
17126 2 }
17127
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_ENEMY)
17128 {
17129 for(int32_t k=0; k<10; k++)
17130 {
17131 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17132 return qe_invalid;
17133 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17134 temp_mapscr->enemy[k] = 0;
17135 }
17136 if(!p_getc(&(temp_mapscr->pattern),f,true))
17137 return qe_invalid;
17138 }
17139
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_CARRY)
17140 {
17141 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17142 return qe_invalid;
17143 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17144 return qe_invalid;
17145 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17146 return qe_invalid;
17147 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17148 return qe_invalid;
17149 }
17150
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_SCRIPT)
17151 {
17152 if(!p_igetw(&(temp_mapscr->script),f,true))
17153 return qe_invalid;
17154 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17155 return qe_invalid;
17156 for ( int32_t q = 0; q < 8; q++ )
17157 {
17158 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17159 return qe_invalid;
17160 }
17161 }
17162
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_UNUSED)
17163 {
17164 for ( int32_t q = 0; q < 10; q++ )
17165 {
17166 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17167 return qe_invalid;
17168 }
17169 for ( int32_t q = 0; q < 10; q++ )
17170 {
17171 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17172 return qe_invalid;
17173 }
17174 for ( int32_t q = 0; q < 10; q++ )
17175 {
17176 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17177 return qe_invalid;
17178 }
17179 for ( int32_t q = 0; q < 10; q++ )
17180 {
17181 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17182 return qe_invalid;
17183 }
17184 }
17185
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4 times.
11 if(scr_has_flags & SCRHAS_SECRETS)
17186 {
17187
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t k=0; k<128; k++)
17188 {
17189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17190 return qe_invalid;
17191 512 }
17192
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t k=0; k<128; k++)
17193 {
17194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17195 return qe_invalid;
17196 512 }
17197
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t k=0; k<128; k++)
17198 {
17199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17200 return qe_invalid;
17201 512 }
17202 4 }
17203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(scr_has_flags & SCRHAS_COMBOFLAG)
17204 {
17205
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 11 times.
1947 for(int32_t k=0; k<176; ++k)
17206 {
17207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1936 times.
1936 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17208 return qe_invalid;
17209 1936 }
17210
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 11 times.
1947 for(int32_t k=0; k<176; ++k)
17211 {
17212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1936 times.
1936 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17213 return qe_invalid;
17214 1936 }
17215
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 11 times.
1947 for(int32_t k=0; k<176; ++k)
17216 {
17217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1936 times.
1936 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17218 return qe_invalid;
17219 1936 }
17220 11 }
17221
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(scr_has_flags & SCRHAS_MISC)
17222 {
17223
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&(temp_mapscr->color),f,true))
17224 return qe_invalid;
17225
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17226 return qe_invalid;
17227
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17228 return qe_invalid;
17229
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17230 return qe_invalid;
17231
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17232 return qe_invalid;
17233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17234 return qe_invalid;
17235
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17236 return qe_invalid;
17237
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17238 return qe_invalid;
17239
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17240 return qe_invalid;
17241 11 }
17242 else
17243 {
17244 temp_mapscr->screen_midi = -1;
17245 temp_mapscr->csensitive = 1;
17246 }
17247 //FFC
17248 11 bool old_ff = version < 25;
17249 11 dword bits = 0;
17250 11 word numffc = 32;
17251
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(old_ff)
17252 {
17253
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&bits,f,true))
17254 return qe_invalid;
17255 11 }
17256 else
17257 {
17258 if(!p_igetw(&numffc,f,true))
17259 return qe_invalid;
17260 }
17261 byte tempbyte;
17262 word tempw;
17263
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
11 static ffcdata nil_ffc;
17264
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 352 times.
363 for(word m = 0; m < numffc; ++m)
17265 {
17266
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 ffcdata& tempffc = (m < MAXFFCS)
17267 352 ? temp_mapscr->ffcs[m]
17268 : nil_ffc; //sanity
17269 352 tempffc.clear();
17270
2/4
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 352 times.
352 if(old_ff && !(bits & (1<<m))) continue;
17271
17272 if(!p_igetw(&tempw,f,true))
17273 return qe_invalid;
17274 if(!old_ff && !tempw) //empty ffc, nothing more to load
17275 continue;
17276 tempffc.setData(tempw);
17277
17278 if(!p_getc(&(tempffc.cset),f,true))
17279 return qe_invalid;
17280 if(!p_igetw(&(tempffc.delay),f,true))
17281 return qe_invalid;
17282 if(!p_igetzf(&(tempffc.x),f,true))
17283 return qe_invalid;
17284 if(!p_igetzf(&(tempffc.y),f,true))
17285 return qe_invalid;
17286 if(!p_igetzf(&(tempffc.vx),f,true))
17287 return qe_invalid;
17288 if(!p_igetzf(&(tempffc.vy),f,true))
17289 return qe_invalid;
17290 if(!p_igetzf(&(tempffc.ax),f,true))
17291 return qe_invalid;
17292 if(!p_igetzf(&(tempffc.ay),f,true))
17293 return qe_invalid;
17294 if(!p_getc(&(tempffc.link),f,true))
17295 return qe_invalid;
17296 if(version < 24)
17297 {
17298 if(!p_getc(&tempbyte,f,true))
17299 return qe_invalid;
17300 tempffc.hxsz = (tempbyte&0x3F)+1;
17301 tempffc.txsz = (tempbyte>>6)+1;
17302 if(!p_getc(&tempbyte,f,true))
17303 return qe_invalid;
17304 tempffc.hysz = (tempbyte&0x3F)+1;
17305 tempffc.tysz = (tempbyte>>6)+1;
17306 }
17307 else
17308 {
17309 if(!p_igetl(&(tempffc.hxsz),f,true))
17310 return qe_invalid;
17311 if(!p_igetl(&(tempffc.hysz),f,true))
17312 return qe_invalid;
17313 if(!p_getc(&(tempffc.txsz),f,true))
17314 return qe_invalid;
17315 if(!p_getc(&(tempffc.tysz),f,true))
17316 return qe_invalid;
17317 }
17318 if(!p_igetl(&(tempffc.flags),f,true))
17319 return qe_invalid;
17320 tempffc.updateSolid();
17321 if(!p_igetw(&(tempffc.script),f,true))
17322 return qe_invalid;
17323 for(auto q = 0; q < 8; ++q)
17324 {
17325 if(!p_igetl(&(tempffc.initd[q]),f,true))
17326 return qe_invalid;
17327 }
17328 if(!p_getc(&(tempbyte),f,true))
17329 return qe_invalid;
17330 tempffc.inita[0]=tempbyte*10000;
17331
17332 if(!p_getc(&(tempbyte),f,true))
17333 return qe_invalid;
17334 tempffc.inita[1]=tempbyte*10000;
17335
17336 tempffc.initialized = false;
17337 }
17338
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 11 times.
1067 for(word m = numffc; m < MAXFFCS; ++m)
17339 {
17340 1056 temp_mapscr->ffcs[m].clear();
17341 1056 }
17342 11 temp_mapscr->update_ffc_count(numffc-1);
17343 //END FFC
17344 }
17345 31427 return 0;
17346 31688 }
17347
17348
17349 25 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17350 {
17351 25 int32_t scr=0;
17352
17353 25 word version=0;
17354 dword dummy;
17355 int32_t screens_to_read;
17356
17357 25 mapscr temp_mapscr;
17358 zcmap temp_map;
17359 word temp_map_count;
17360 dword section_size;
17361
17362
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17363 {
17364 screens_to_read=MAPSCRS192b136;
17365 }
17366 else
17367 {
17368 25 screens_to_read=MAPSCRS;
17369 }
17370
17371
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version > 0x192)
17372 {
17373 //section version info
17374
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&version,f,true))
17375 {
17376 return qe_invalid;
17377 }
17378
17379 25 FFCore.quest_format[vMaps] = version;
17380
17381 //al_trace("Maps version %d\n", version);
17382
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&dummy,f,true))
17383 {
17384 return qe_invalid;
17385 }
17386
17387 //section size
17388
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetl(&section_size,f,true))
17389 {
17390 return qe_invalid;
17391 }
17392
17393 //finally... section data
17394
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_map_count,f,true))
17395 {
17396 return 5;
17397 }
17398 25 }
17399 else
17400 {
17401 temp_map_count=map_count;
17402 }
17403
17404
17405
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(keepdata)
17406 {
17407 25 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17408
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 TheMaps.resize(_mapsSize);
17409
17410
2/2
✓ Branch 0 taken 31688 times.
✓ Branch 1 taken 25 times.
31713 for(int32_t i(0); i<_mapsSize; i++)
17411
1/2
✓ Branch 0 taken 31688 times.
✗ Branch 1 not taken.
31688 TheMaps[i].zero_memory();
17412
17413 // Used to be done for each screen
17414
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 25 times.
3225 for(int32_t i=0; i<MAXFFCS; i++)
17415 {
17416 3200 ffcScriptData[i].a[0] = 10000;
17417 3200 ffcScriptData[i].a[1] = 10000;
17418 3200 }
17419
17420 25 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17421 25 }
17422
17423
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 temp_mapscr.zero_memory();
17424
17425 25 memset(&temp_map, 0, sizeof(zcmap));
17426 25 temp_map.scrResWidth = 256;
17427 25 temp_map.scrResHeight = 224;
17428 25 temp_map.tileWidth = 16;
17429 25 temp_map.tileHeight = 11;
17430 25 temp_map.viewWidth = 256;
17431 25 temp_map.viewHeight = 176;
17432 25 temp_map.viewX = 0;
17433 25 temp_map.viewY = 64;
17434 25 temp_map.subaWidth = 256;
17435 25 temp_map.subaHeight = 168;
17436 25 temp_map.subaTrans = false;
17437 25 temp_map.subpWidth = 256;
17438 25 temp_map.subpHeight = 56;
17439 25 temp_map.subpTrans = false;
17440
4/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 233 times.
258 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17441 {
17442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233 times.
233 if(keepdata==true) //!TODO Trim fully
17443 {
17444 233 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17445 233 }
17446 233 byte valid=1;
17447
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 231 times.
233 if(version > 22)
17448 {
17449
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&valid,f,true))
17450 return qe_invalid;
17451 2 }
17452
2/2
✓ Branch 0 taken 31688 times.
✓ Branch 1 taken 233 times.
31921 for(int32_t j=0; j<screens_to_read; j++)
17453 {
17454 31688 scr=i*MAPSCRS+j;
17455
1/2
✓ Branch 0 taken 31688 times.
✗ Branch 1 not taken.
31688 clear_screen(&temp_mapscr);
17456
1/2
✓ Branch 0 taken 31688 times.
✗ Branch 1 not taken.
31688 if(valid)
17457
1/2
✓ Branch 0 taken 31688 times.
✗ Branch 1 not taken.
31688 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17458
17459
1/2
✓ Branch 0 taken 31688 times.
✗ Branch 1 not taken.
31688 if(keepdata==true)
17460 {
17461
1/2
✓ Branch 0 taken 31688 times.
✗ Branch 1 not taken.
31688 TheMaps[scr] = temp_mapscr;
17462 31688 }
17463 31688 }
17464
17465
1/2
✓ Branch 0 taken 233 times.
✗ Branch 1 not taken.
233 if(keepdata==true)
17466 {
17467
2/6
✓ Branch 0 taken 233 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 233 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
233 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17468 {
17469 int32_t index = (i*MAPSCRS+132);
17470
17471 TheMaps[index]=TheMaps[index-1];
17472
17473 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17474 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17475 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17476
17477 for(int32_t j=133; j<MAPSCRS; j++)
17478 {
17479 scr=i*MAPSCRS+j;
17480
17481 TheMaps[scr].zero_memory();
17482 TheMaps[scr].valid = mVERSION;
17483 TheMaps[scr].screen_midi = -1;
17484 TheMaps[scr].csensitive = 1;
17485 }
17486 }
17487
17488
2/6
✓ Branch 0 taken 233 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 233 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
233 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17489 {
17490 for(int32_t j=0; j<MAPSCRS; j++)
17491 {
17492 scr=i*MAPSCRS+j;
17493 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17494
17495 for(int32_t k=0; k<128; k++)
17496 {
17497 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17498 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17499 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17500 }
17501 }
17502 }
17503 233 }
17504 233 }
17505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
17506 {
17507 25 map_count = temp_map_count;
17508 25 }
17509
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 clear_screen(&temp_mapscr);
17510 25 return 0;
17511 25 }
17512
17513
17514 24 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17515 {
17516 24 reset_combo_animations();
17517 24 reset_combo_animations2();
17518
17519 24 init_combo_classes();
17520
17521 // combos
17522 24 word combos_used=0;
17523 int32_t dummy;
17524 byte padding;
17525 24 newcombo temp_combo;
17526 //word section_cversion=0;
17527
17528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(keepdata==true)
17529 {
17530
2/2
✓ Branch 0 taken 1566720 times.
✓ Branch 1 taken 24 times.
1566744 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17531 1566720 combobuf[q].clear();
17532 24 }
17533
17534 // if(version > 0x192)
17535 // {
17536 // //section version info
17537 // if(!p_igetw(&section_version,f,true))
17538 // {
17539 // return qe_invalid;
17540 // }
17541
17542 // FFCore.quest_format[vCombos] = section_version;
17543
17544 // //al_trace("Combos version %d\n", section_version);
17545 // if(!p_igetw(&section_cversion,f,true))
17546 // {
17547 // return qe_invalid;
17548 // }
17549
17550 // //section size
17551 // if(!p_igetl(&dummy,f,true))
17552 // {
17553 // return qe_invalid;
17554 // }
17555 // }
17556
17557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(version < 0x174)
17558 {
17559 combos_used=1024;
17560 }
17561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 else if(version < 0x191)
17562 {
17563 combos_used=2048;
17564 }
17565 else
17566 {
17567
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&combos_used,f,true))
17568 {
17569 return qe_invalid;
17570 }
17571 }
17572
17573 //finally... section data
17574
2/2
✓ Branch 0 taken 27498 times.
✓ Branch 1 taken 24 times.
27522 for(int32_t i=0; i<combos_used; i++)
17575 {
17576 27498 temp_combo.clear();
17577
17578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if ( section_version >= 11 )
17579 {
17580 if(!p_igetl(&temp_combo.tile,f,true))
17581 {
17582 return qe_invalid;
17583 }
17584 }
17585 else
17586 {
17587
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_igetw(&temp_combo.tile,f,true))
17588 {
17589 return qe_invalid;
17590 }
17591 }
17592 27498 temp_combo.o_tile = temp_combo.tile;
17593
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.flip,f,true))
17594 {
17595 return qe_invalid;
17596 }
17597
17598
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.walk,f,true))
17599 {
17600 return qe_invalid;
17601 }
17602
17603
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.type,f,true))
17604 {
17605 return qe_invalid;
17606 }
17607
17608
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.csets,f,true))
17609 {
17610 return qe_invalid;
17611 }
17612
17613
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(version < 0x193)
17614 {
17615 if(!p_getc(&padding,f,true))
17616 {
17617 return qe_invalid;
17618 }
17619
17620 if(!p_getc(&padding,f,true))
17621 {
17622 return qe_invalid;
17623 }
17624
17625 if(version < 0x192)
17626 {
17627 if(version == 0x191)
17628 {
17629 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17630 {
17631 if(!p_getc(&padding,f,true))
17632 {
17633 return qe_invalid;
17634 }
17635 }
17636 }
17637
17638 if(keepdata==true)
17639 {
17640 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
17641 }
17642
17643 continue;
17644 }
17645 }
17646
17647
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.frames,f,true))
17648 {
17649 return qe_invalid;
17650 }
17651
17652
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.speed,f,true))
17653 {
17654 return qe_invalid;
17655 }
17656
17657
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_igetw(&temp_combo.nextcombo,f,true))
17658 {
17659 return qe_invalid;
17660 }
17661
17662
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.nextcset,f,true))
17663 {
17664 return qe_invalid;
17665 }
17666
17667 //Base flag
17668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version>=3)
17669 {
17670
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.flag,f,true))
17671 {
17672 return qe_invalid;
17673 }
17674 27498 }
17675
17676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version>=4)
17677 {
17678
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.skipanim,f,true))
17679 {
17680 return qe_invalid;
17681 }
17682
17683
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_igetw(&temp_combo.nexttimer,f,true))
17684 {
17685 return qe_invalid;
17686 }
17687 27498 }
17688
17689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version>=5)
17690 {
17691
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.skipanimy,f,true))
17692 {
17693 return qe_invalid;
17694 }
17695 27498 }
17696
17697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version>=6)
17698 {
17699
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(!p_getc(&temp_combo.animflags,f,true))
17700 {
17701 return qe_invalid;
17702 }
17703
17704
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(section_version == 6)
17705 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17706 27498 }
17707
17708
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(section_version>=8) //combo Attributes[4] and userflags.
17709 {
17710 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17711 {
17712 if(!p_igetl(&temp_combo.attributes[q],f,true))
17713 {
17714 return qe_invalid;
17715 }
17716 }
17717 if(!p_igetl(&temp_combo.usrflags,f,true))
17718 {
17719 return qe_invalid;
17720 }
17721 if(section_version >= 20)
17722 {
17723 if(!p_igetw(&temp_combo.genflags,f,true))
17724 {
17725 return qe_invalid;
17726 }
17727 }
17728 else
17729 {
17730 temp_combo.genflags = 0;
17731 switch(temp_combo.type)
17732 {
17733 case cPUSH_WAIT: case cPUSH_HEAVY:
17734 case cPUSH_HW: case cL_STATUE:
17735 case cR_STATUE: case cPUSH_HEAVY2:
17736 case cPUSH_HW2: case cPOUND:
17737 case cC_STATUE: case cMIRROR:
17738 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17739 case cMAGICPRISM: case cMAGICPRISM4:
17740 case cMAGICSPONGE: case cEYEBALL_A:
17741 case cEYEBALL_B: case cEYEBALL_4:
17742 case cBUSH: case cFLOWERS:
17743 case cLOCKBLOCK: case cLOCKBLOCK2:
17744 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17745 case cCHEST: case cCHEST2:
17746 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17747 case cBOSSCHEST: case cBOSSCHEST2:
17748 case cBUSHNEXT: case cBUSHTOUCHY:
17749 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17750 case cSIGNPOST: case cCSWITCHBLOCK:
17751 case cTORCH: case cTRIGGERGENERIC:
17752 if(temp_combo.usrflags & cflag16)
17753 {
17754 temp_combo.genflags |= cflag1;
17755 temp_combo.usrflags &= ~cflag16;
17756 }
17757 break; }
17758 }
17759 }
17760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version>=10) //combo trigger flags
17761 {
17762 for ( int32_t q = 0; q < 3; q++ )
17763 {
17764 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17765 {
17766 return qe_invalid;
17767 }
17768 }
17769 }
17770
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17771 {
17772 for ( int32_t q = 0; q < 2; q++ )
17773 {
17774 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17775 {
17776 return qe_invalid;
17777 }
17778 }
17779 }
17780
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(section_version >= 9)
17781 {
17782 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17783 {
17784 return qe_invalid;
17785 }
17786 }
17787
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(section_version >= 22)
17788 {
17789 if(!p_getc(&temp_combo.triggerbtn,f,true))
17790 {
17791 return qe_invalid;
17792 }
17793 }
17794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version < 23)
17795 {
17796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17797 {
17798 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17799 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17800 case cTRIGGERGENERIC: case cCSWITCH:
17801 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17802 }
17803 27498 }
17804
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(section_version >= 24)
17805 {
17806 if(!p_getc(&temp_combo.triggeritem,f,true))
17807 {
17808 return qe_invalid;
17809 }
17810 if(!p_getc(&temp_combo.trigtimer,f,true))
17811 {
17812 return qe_invalid;
17813 }
17814 }
17815
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(section_version >= 25)
17816 {
17817 if(!p_getc(&temp_combo.trigsfx,f,true))
17818 {
17819 return qe_invalid;
17820 }
17821 }
17822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version >= 27)
17823 {
17824 if(!p_igetl(&temp_combo.trigchange,f,true))
17825 {
17826 return qe_invalid;
17827 }
17828 }
17829 else
17830 {
17831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17832 temp_combo.trigchange = 1;
17833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17834 temp_combo.trigchange = -1;
17835 27498 else temp_combo.trigchange = 0;
17836 27498 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17837 }
17838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version >= 29)
17839 {
17840 if(!p_igetw(&temp_combo.trigprox,f,true))
17841 {
17842 return qe_invalid;
17843 }
17844 if(!p_getc(&temp_combo.trigctr,f,true))
17845 {
17846 return qe_invalid;
17847 }
17848 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17849 {
17850 return qe_invalid;
17851 }
17852 }
17853 else
17854 {
17855 27498 temp_combo.trigprox = 0;
17856 27498 temp_combo.trigctr = 0;
17857 27498 temp_combo.trigctramnt = 0;
17858 }
17859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version >= 30)
17860 {
17861 if(!p_getc(&temp_combo.triglbeam,f,true))
17862 {
17863 return qe_invalid;
17864 }
17865 }
17866 27498 else temp_combo.triglbeam = 0;
17867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version >= 31)
17868 {
17869 if(!p_getc(&temp_combo.trigcschange,f,true))
17870 {
17871 return qe_invalid;
17872 }
17873 if(!p_igetw(&temp_combo.spawnitem,f,true))
17874 {
17875 return qe_invalid;
17876 }
17877 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17878 {
17879 return qe_invalid;
17880 }
17881 if(!p_getc(&temp_combo.exstate,f,true))
17882 {
17883 return qe_invalid;
17884 }
17885 if(!p_igetl(&temp_combo.spawnip,f,true))
17886 {
17887 return qe_invalid;
17888 }
17889 if(!p_getc(&temp_combo.trigcopycat,f,true))
17890 {
17891 return qe_invalid;
17892 }
17893 }
17894 else
17895 {
17896 27498 temp_combo.trigcschange = 0;
17897 27498 temp_combo.spawnitem = 0;
17898 27498 temp_combo.spawnenemy = 0;
17899 27498 temp_combo.exstate = -1;
17900 27498 temp_combo.spawnip = 0;
17901 27498 temp_combo.trigcopycat = 0;
17902 }
17903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version >= 32)
17904 {
17905 if(!p_getc(&temp_combo.trigcooldown,f,true))
17906 {
17907 return qe_invalid;
17908 }
17909 }
17910 else
17911 {
17912 27498 temp_combo.trigcooldown = 0;
17913 }
17914
17915
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(section_version>=12) //combo label
17916 {
17917 for ( int32_t q = 0; q < 11; q++ )
17918 {
17919 if(!p_getc(&temp_combo.label[q],f,true))
17920 {
17921 return qe_invalid;
17922 }
17923 }
17924 }
17925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version<12) //combo label
17926 {
17927
2/2
✓ Branch 0 taken 302478 times.
✓ Branch 1 taken 27498 times.
329976 for ( int32_t q = 0; q < 11; q++ )
17928 {
17929 302478 temp_combo.label[q] = 0;
17930 302478 }
17931 27498 }
17932 //al_trace("Read combo label\n");
17933
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(section_version>=13) //attribytes[4]
17934 {
17935 for ( int32_t q = 0; q < 4; q++ ) //Bad Zoria, don't mix constants with hardcodes
17936 {
17937 if(!p_getc(&temp_combo.attribytes[q],f,true))
17938 {
17939 return qe_invalid;
17940 }
17941 }
17942
17943 }
17944 //al_trace("Read combo attribytes\n");
17945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if( section_version < 13 )
17946 {
17947
2/2
✓ Branch 0 taken 109992 times.
✓ Branch 1 taken 27498 times.
137490 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17948 {
17949 109992 temp_combo.attribytes[q] = 0;
17950 109992 }
17951
17952 27498 }
17953 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17954 * This fixes a poor implementation of a ->next flag bug thing.
17955 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17956 * there was a version bump a few weeks before a change that broke stuff.
17957 */
17958
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27498 if (section_version >= 13 && section_version < 21)
17959 {
17960 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17961 }
17962 //combo scripts
17963
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(section_version>=14)
17964 {
17965 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
17966 for ( int32_t q = 0; q < 2; q++ )
17967 {
17968 if(!p_igetl(&temp_combo.initd[q],f,true))
17969 {
17970 return qe_invalid;
17971 }
17972 }
17973
17974 }
17975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version<14)
17976 {
17977 27498 temp_combo.script = 0;
17978
2/2
✓ Branch 0 taken 54996 times.
✓ Branch 1 taken 27498 times.
82494 for ( int32_t q = 0; q < 2; q++ )
17979 {
17980 54996 temp_combo.initd[q] = 0;
17981 54996 }
17982 27498 }
17983 //al_trace("Read combo script data\n");
17984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version>=15)
17985 {
17986 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17987 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17988 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17989 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17990 }
17991 else
17992 {
17993 27498 temp_combo.o_tile = temp_combo.tile;
17994 27498 temp_combo.cur_frame = 0;
17995 27498 temp_combo.aclk = 0;
17996 }
17997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version>=17) //attribytes[4]
17998 {
17999 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18000 {
18001 if(!p_getc(&temp_combo.attribytes[q],f,true))
18002 {
18003 return qe_invalid;
18004 }
18005 }
18006 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18007 {
18008 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18009 {
18010 return qe_invalid;
18011 }
18012 }
18013
18014 }
18015 else
18016 {
18017
2/2
✓ Branch 0 taken 109992 times.
✓ Branch 1 taken 27498 times.
137490 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18018 {
18019 109992 temp_combo.attribytes[q] = 0;
18020 109992 }
18021
2/2
✓ Branch 0 taken 219984 times.
✓ Branch 1 taken 27498 times.
247482 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18022 {
18023 219984 temp_combo.attrishorts[q] = 0;
18024 219984 }
18025 }
18026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version<18) //upper bits for .walk
18027 {
18028 27498 temp_combo.walk |= 0xF0; //All on by default for old quests -E
18029 27498 }
18030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version < 19)
18031 {
18032
2/2
✓ Branch 0 taken 109992 times.
✓ Branch 1 taken 27498 times.
137490 for(int32_t q = 0; q < 4; ++q)
18033 {
18034 109992 temp_combo.attributes[q] *= 10000L;
18035 109992 }
18036 27498 }
18037
18038
1/2
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
27498 if(version < 0x193)
18039 {
18040 for(int32_t q=0; q<11; q++)
18041 {
18042 if(!p_getc(&dummy,f,true))
18043 {
18044 return qe_invalid;
18045 }
18046 }
18047 }
18048
18049 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
18050
2/6
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27498 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27498 if((version < 0x211)||((version == 0x211)&&(build<7)))
18051 {
18052 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
18053 {
18054 switch(temp_combo.tile)
18055 {
18056 case 130:
18057 temp_combo.tile = 132;
18058 break;
18059
18060 case 131:
18061 temp_combo.tile = 133;
18062 break;
18063
18064 case 132:
18065 temp_combo.tile = 130;
18066 break;
18067
18068 case 133:
18069 temp_combo.tile = 131;
18070 break;
18071 }
18072 }
18073 }
18074
18075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version < 25)
18076 {
18077
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 27320 times.
27498 switch(temp_combo.type)
18078 {
18079 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(!(temp_combo.usrflags & cflag3))
18081 178 temp_combo.attribytes[3] = WAV_DOOR;
18082 178 temp_combo.usrflags &= ~cflag3;
18083 178 break;
18084 }
18085 27498 }
18086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version < 26)
18087 {
18088
2/2
✓ Branch 0 taken 27426 times.
✓ Branch 1 taken 72 times.
27498 if(temp_combo.type == cARMOS)
18089 {
18090
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(temp_combo.usrflags & cflag1)
18091 temp_combo.usrflags |= cflag3;
18092 72 }
18093 27498 }
18094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 if(section_version < 28)
18095 {
18096
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 27408 times.
27498 switch(temp_combo.type)
18097 {
18098 case cLOCKBLOCK: case cLOCKEDCHEST:
18099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(temp_combo.usrflags & cflag7)
18100 temp_combo.usrflags |= cflag8;
18101 90 else temp_combo.usrflags &= ~cflag8;
18102 90 temp_combo.usrflags &= ~cflag7;
18103 90 break;
18104 }
18105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27498 times.
27498 switch(temp_combo.type)
18106 {
18107 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18108 temp_combo.attrishorts[2] = -1;
18109 temp_combo.usrflags |= cflag7;
18110 break;
18111 }
18112 27498 }
18113
18114
2/4
✓ Branch 0 taken 27498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27498 times.
27498 if(keepdata==true && i>=start_combo)
18115 {
18116 27498 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18117 27498 }
18118 27498 }
18119
18120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(keepdata==true)
18121 {
18122
2/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18123 {
18124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18125 {
18126 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18127 {
18128 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18129 }
18130 }
18131 }
18132
18133 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if(version == 0x210 && !is_zquest())
18135 {
18136 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18137 if(combobuf[tmpcounter].type == cLADDERONLY)
18138 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18139 }
18140
18141
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(section_version<7)
18142 {
18143 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18144 {
18145 switch(combobuf[tmpcounter].type)
18146 {
18147 case cSLASH:
18148 combobuf[tmpcounter].type=cSLASHTOUCHY;
18149 break;
18150
18151 case cSLASHITEM:
18152 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18153 break;
18154
18155 case cBUSH:
18156 combobuf[tmpcounter].type=cBUSHTOUCHY;
18157 break;
18158
18159 case cFLOWERS:
18160 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18161 break;
18162
18163 case cTALLGRASS:
18164 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18165 break;
18166
18167 case cSLASHNEXT:
18168 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18169 break;
18170
18171 case cSLASHNEXTITEM:
18172 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18173 break;
18174
18175 case cBUSHNEXT:
18176 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18177 break;
18178 }
18179 }
18180 }
18181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (section_version < 16)
18182 {
18183
2/2
✓ Branch 0 taken 1566720 times.
✓ Branch 1 taken 24 times.
1566744 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18184 {
18185
2/2
✓ Branch 0 taken 1566112 times.
✓ Branch 1 taken 608 times.
1566720 if (combobuf[tmpcounter].type == cWATER)
18186 {
18187 608 combobuf[tmpcounter].attributes[0] = 40000L;
18188 608 }
18189 1566720 }
18190 24 }
18191
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18192 {
18193 combobuf[0].walk = 0xF0;
18194 combobuf[0].type = 0;
18195 combobuf[0].flag = 0;
18196 }
18197 24 }
18198
18199 //Now for the new combo alias reset
18200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if(section_version<2 && keepdata)
18201 {
18202 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18203 {
18204 combo_aliases[j].width = 0;
18205 combo_aliases[j].height = 0;
18206 combo_aliases[j].layermask = 0;
18207
18208 if(combo_aliases[j].combos != NULL)
18209 {
18210 delete[] combo_aliases[j].combos;
18211 }
18212
18213 if(combo_aliases[j].csets != NULL)
18214 {
18215 delete[] combo_aliases[j].csets;
18216 }
18217
18218 combo_aliases[j].combos = new word[1];
18219 combo_aliases[j].csets = new byte[1];
18220 combo_aliases[j].combos[0] = 0;
18221 combo_aliases[j].csets[0] = 0;
18222 }
18223 }
18224
18225
18226 24 setup_combo_animations();
18227 24 setup_combo_animations2();
18228 24 return 0;
18229 24 }
18230 5124 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18231 {
18232 byte combo_has_flags;
18233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
5124 if(!p_getc(&combo_has_flags,f,true))
18234 return qe_invalid;
18235
18236 5124 temp_combo.clear();
18237
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 1562 times.
5124 if(combo_has_flags)
18238 {
18239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1562 times.
1562 if(combo_has_flags&CHAS_GENERAL)
18240 {
18241
1/2
✓ Branch 0 taken 1562 times.
✗ Branch 1 not taken.
1562 if(!p_igetl(&temp_combo.tile,f,true))
18242 {
18243 return qe_invalid;
18244 }
18245 1562 temp_combo.o_tile = temp_combo.tile;
18246
18247
1/2
✓ Branch 0 taken 1562 times.
✗ Branch 1 not taken.
1562 if(!p_getc(&temp_combo.flip,f,true))
18248 {
18249 return qe_invalid;
18250 }
18251
18252
1/2
✓ Branch 0 taken 1562 times.
✗ Branch 1 not taken.
1562 if(!p_getc(&temp_combo.walk,f,true))
18253 {
18254 return qe_invalid;
18255 }
18256
18257
1/2
✓ Branch 0 taken 1562 times.
✗ Branch 1 not taken.
1562 if(!p_getc(&temp_combo.type,f,true))
18258 {
18259 return qe_invalid;
18260 }
18261
18262
1/2
✓ Branch 0 taken 1562 times.
✗ Branch 1 not taken.
1562 if(!p_getc(&temp_combo.flag,f,true))
18263 {
18264 return qe_invalid;
18265 }
18266
18267
1/2
✓ Branch 0 taken 1562 times.
✗ Branch 1 not taken.
1562 if(!p_getc(&temp_combo.csets,f,true))
18268 {
18269 return qe_invalid;
18270 }
18271 1562 }
18272
1/2
✓ Branch 0 taken 1562 times.
✗ Branch 1 not taken.
1562 if(combo_has_flags&CHAS_SCRIPT)
18273 {
18274 for ( int32_t q = 0; q < 11; q++ )
18275 {
18276 if(!p_getc(&temp_combo.label[q],f,true))
18277 {
18278 return qe_invalid;
18279 }
18280 }
18281 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18282 for ( int32_t q = 0; q < 2; q++ )
18283 {
18284 if(!p_igetl(&temp_combo.initd[q],f,true))
18285 {
18286 return qe_invalid;
18287 }
18288 }
18289 }
18290
2/2
✓ Branch 0 taken 1318 times.
✓ Branch 1 taken 244 times.
1562 if(combo_has_flags&CHAS_ANIM)
18291 {
18292
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_getc(&temp_combo.frames,f,true))
18293 {
18294 return qe_invalid;
18295 }
18296
18297
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_getc(&temp_combo.speed,f,true))
18298 {
18299 return qe_invalid;
18300 }
18301
18302
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_igetw(&temp_combo.nextcombo,f,true))
18303 {
18304 return qe_invalid;
18305 }
18306
18307
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_getc(&temp_combo.nextcset,f,true))
18308 {
18309 return qe_invalid;
18310 }
18311
18312
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_getc(&temp_combo.skipanim,f,true))
18313 {
18314 return qe_invalid;
18315 }
18316
18317
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_getc(&temp_combo.skipanimy,f,true))
18318 {
18319 return qe_invalid;
18320 }
18321
18322
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_getc(&temp_combo.animflags,f,true))
18323 {
18324 return qe_invalid;
18325 }
18326 244 }
18327
2/2
✓ Branch 0 taken 1362 times.
✓ Branch 1 taken 200 times.
1562 if(combo_has_flags&CHAS_ATTRIB)
18328 {
18329
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for ( int32_t q = 0; q < 4; q++ )
18330 {
18331
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetl(&temp_combo.attributes[q],f,true))
18332 {
18333 return qe_invalid;
18334 }
18335 800 }
18336
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 200 times.
1800 for ( int32_t q = 0; q < 8; q++ )
18337 {
18338
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 if(!p_getc(&temp_combo.attribytes[q],f,true))
18339 {
18340 return qe_invalid;
18341 }
18342 1600 }
18343
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 200 times.
1800 for ( int32_t q = 0; q < 8; q++ )
18344 {
18345
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18346 {
18347 return qe_invalid;
18348 }
18349 1600 }
18350 200 }
18351
2/2
✓ Branch 0 taken 1502 times.
✓ Branch 1 taken 60 times.
1562 if(combo_has_flags&CHAS_FLAG)
18352 {
18353
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetl(&temp_combo.usrflags,f,true))
18354 {
18355 return qe_invalid;
18356 }
18357
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_combo.genflags,f,true))
18358 {
18359 return qe_invalid;
18360 }
18361 60 }
18362
2/2
✓ Branch 0 taken 1553 times.
✓ Branch 1 taken 9 times.
1562 if(combo_has_flags&CHAS_TRIG)
18363 {
18364
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
36 for ( int32_t q = 0; q < 3; q++ )
18365 {
18366
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18367 {
18368 return qe_invalid;
18369 }
18370 27 }
18371
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18372 {
18373 return qe_invalid;
18374 }
18375
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.triggerbtn,f,true))
18376 {
18377 return qe_invalid;
18378 }
18379
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.triggeritem,f,true))
18380 {
18381 return qe_invalid;
18382 }
18383
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.trigtimer,f,true))
18384 {
18385 return qe_invalid;
18386 }
18387
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.trigsfx,f,true))
18388 {
18389 return qe_invalid;
18390 }
18391
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&temp_combo.trigchange,f,true))
18392 {
18393 return qe_invalid;
18394 }
18395
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_combo.trigprox,f,true))
18396 {
18397 return qe_invalid;
18398 }
18399
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.trigctr,f,true))
18400 {
18401 return qe_invalid;
18402 }
18403
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18404 {
18405 return qe_invalid;
18406 }
18407
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.triglbeam,f,true))
18408 {
18409 return qe_invalid;
18410 }
18411
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.trigcschange,f,true))
18412 {
18413 return qe_invalid;
18414 }
18415
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_combo.spawnitem,f,true))
18416 {
18417 return qe_invalid;
18418 }
18419
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18420 {
18421 return qe_invalid;
18422 }
18423
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.exstate,f,true))
18424 {
18425 return qe_invalid;
18426 }
18427
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&temp_combo.spawnip,f,true))
18428 {
18429 return qe_invalid;
18430 }
18431
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.trigcopycat,f,true))
18432 {
18433 return qe_invalid;
18434 }
18435
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.trigcooldown,f,true))
18436 {
18437 return qe_invalid;
18438 }
18439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(s_version >= 35)
18440 {
18441
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18442 {
18443 return qe_invalid;
18444 }
18445
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_combo.prompt_cs,f,true))
18446 {
18447 return qe_invalid;
18448 }
18449
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_combo.prompt_x,f,true))
18450 {
18451 return qe_invalid;
18452 }
18453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!p_igetw(&temp_combo.prompt_y,f,true))
18454 {
18455 return qe_invalid;
18456 }
18457 9 }
18458 9 }
18459
2/2
✓ Branch 0 taken 1558 times.
✓ Branch 1 taken 4 times.
1562 if(combo_has_flags&CHAS_LIFT)
18460 {
18461
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_combo.liftcmb,f,true))
18462 return qe_invalid;
18463
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftcs,f,true))
18464 return qe_invalid;
18465
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18466 return qe_invalid;
18467
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftundercs,f,true))
18468 return qe_invalid;
18469
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftdmg,f,true))
18470 return qe_invalid;
18471
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftlvl,f,true))
18472 return qe_invalid;
18473
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftitm,f,true))
18474 return qe_invalid;
18475
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftflags,f,true))
18476 return qe_invalid;
18477
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftgfx,f,true))
18478 return qe_invalid;
18479
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftsprite,f,true))
18480 return qe_invalid;
18481
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftsfx,f,true))
18482 return qe_invalid;
18483
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18484 return qe_invalid;
18485
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18486 return qe_invalid;
18487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(s_version >= 34)
18488 {
18489
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.lifthei,f,true))
18490 return qe_invalid;
18491
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_combo.lifttime,f,true))
18492 return qe_invalid;
18493 4 }
18494 4 }
18495 1562 }
18496 5124 return 0;
18497 5124 }
18498 25 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18499 {
18500 25 word section_version=0;
18501 25 word section_cversion=0;
18502 25 word combos_used=0;
18503 int32_t dummy;
18504 byte padding;
18505 25 newcombo temp_combo;
18506
18507 25 reset_combo_animations();
18508 25 reset_combo_animations2();
18509 25 init_combo_classes();
18510
18511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true) //reset combos
18512 {
18513
2/2
✓ Branch 0 taken 1632000 times.
✓ Branch 1 taken 25 times.
1632025 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18514 1632000 combobuf[q].clear();
18515 25 }
18516
18517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(version > 0x192) //Version info
18518 {
18519
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&section_version,f,true))
18520 {
18521 return qe_invalid;
18522 }
18523 25 FFCore.quest_format[vCombos] = section_version;
18524
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&section_cversion,f,true))
18525 {
18526 return qe_invalid;
18527 }
18528
18529 //section size
18530
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
18531 {
18532 return qe_invalid;
18533 }
18534 25 }
18535
18536
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(section_version > 32) //Cleanup time!
18537 {
18538
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&combos_used,f,true))
18539 {
18540 return qe_invalid;
18541 }
18542
2/2
✓ Branch 0 taken 5124 times.
✓ Branch 1 taken 1 times.
5125 for(int32_t i=0; i<combos_used; i++)
18543 {
18544 5124 auto ret = readcombo_loop(f,section_version,temp_combo);
18545
1/2
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
5124 if(ret) return ret;
18546
2/4
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5124 times.
5124 if(keepdata==true && i>=start_combo)
18547 5124 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18548 5124 }
18549 1 }
18550 else //Call the old function for all old versions
18551 {
18552 24 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(ret) return ret; //error, end read
18554 }
18555
18556
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(keepdata && false/*section_version < 34*/)
18557 {
18558 for(int32_t i=start_combo; i<combos_used; i++)
18559 {
18560 newcombo& cmb = combobuf[i];
18561 //Do anything to 'cmb' needed for version handling
18562 }
18563 }
18564
18565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
18566 {
18567
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18568 {
18569 1 combobuf[0].walk = 0xF0;
18570 1 combobuf[0].type = 0;
18571 1 combobuf[0].flag = 0;
18572 1 }
18573 25 }
18574
18575 25 setup_combo_animations();
18576 25 setup_combo_animations2();
18577 25 return 0;
18578 25 }
18579
18580 25 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18581 {
18582 //these are here to bypass compiler warnings about unused arguments
18583 25 Header=Header;
18584 25 version=version;
18585 25 build=build;
18586
18587 int32_t dummy;
18588 25 word sversion=0, c_sversion;
18589
18590 //section version info
18591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&sversion,f,true))
18592 {
18593 return qe_invalid;
18594 }
18595
18596 25 FFCore.quest_format[vComboAliases] = sversion;
18597
18598 //al_trace("Combo aliases version %d\n", sversion);
18599
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&c_sversion,f,true))
18600 {
18601 return qe_invalid;
18602 }
18603
18604 //section size
18605
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
18606 {
18607 return qe_invalid;
18608 }
18609
18610 25 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18611
18612
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18613 {
18614 24 max_num_combo_aliases = MAX250COMBOALIASES;
18615 24 }
18616
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18617 {
18618 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18619 }
18620
18621
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 25 times.
57369 for(int32_t j=0; j<max_num_combo_aliases; j++)
18622 {
18623 byte width,height,mask,tempcset;
18624 int32_t count;
18625 word tempword;
18626 byte tempbyte;
18627
18628
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&tempword,f,true))
18629 {
18630 return qe_invalid;
18631 }
18632
18633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(keepdata)
18634 {
18635 57344 combo_aliases[j].combo = tempword;
18636 57344 }
18637
18638
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&tempbyte,f,true))
18639 {
18640 return qe_invalid;
18641 }
18642
18643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(keepdata)
18644 {
18645 57344 combo_aliases[j].cset = tempbyte;
18646 57344 }
18647
18648
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&width,f,true))
18649 {
18650 return qe_invalid;
18651 }
18652
18653
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&height,f,true))
18654 {
18655 return qe_invalid;
18656 }
18657
18658
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&mask,f,true))
18659 {
18660 return qe_invalid;
18661 }
18662
18663 57344 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18664
18665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(keepdata)
18666 {
18667
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(combo_aliases[j].combos != NULL)
18668 {
18669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 delete[] combo_aliases[j].combos;
18670 57344 }
18671
18672
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(combo_aliases[j].csets != NULL)
18673 {
18674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 delete[] combo_aliases[j].csets;
18675 57344 }
18676
18677 57344 combo_aliases[j].width = width;
18678 57344 combo_aliases[j].height = height;
18679 57344 combo_aliases[j].layermask = mask;
18680 57344 combo_aliases[j].combos = new word[count];
18681 57344 combo_aliases[j].csets = new byte[count];
18682 57344 }
18683
18684
2/2
✓ Branch 0 taken 57592 times.
✓ Branch 1 taken 57344 times.
114936 for(int32_t k=0; k<count; k++)
18685 {
18686
1/2
✓ Branch 0 taken 57592 times.
✗ Branch 1 not taken.
57592 if(!p_igetw(&tempword,f,true))
18687 {
18688 return qe_invalid;
18689 }
18690
18691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57592 times.
57592 if(keepdata)
18692 {
18693 57592 combo_aliases[j].combos[k] = tempword;
18694 57592 }
18695 57592 }
18696
18697
2/2
✓ Branch 0 taken 57592 times.
✓ Branch 1 taken 57344 times.
114936 for(int32_t k=0; k<count; k++)
18698 {
18699
1/2
✓ Branch 0 taken 57592 times.
✗ Branch 1 not taken.
57592 if(!p_getc(&tempcset,f,true))
18700 {
18701 return qe_invalid;
18702 }
18703
18704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57592 times.
57592 if(keepdata)
18705 {
18706 57592 combo_aliases[j].csets[k] = tempcset;
18707 57592 }
18708 57592 }
18709 57344 }
18710
18711 25 word num_combo_pools = 0;
18712
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(sversion >= 4)
18713 {
18714
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&num_combo_pools,f,true))
18715 {
18716 return qe_invalid;
18717 }
18718 1 }
18719
18720
2/2
✓ Branch 0 taken 204800 times.
✓ Branch 1 taken 25 times.
204825 for(combo_pool& pool : combo_pools)
18721 {
18722 204800 pool.clear();
18723 }
18724
18725 25 combo_pool temp_cpool;
18726
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 25 times.
28 for(word cp = 0; cp < num_combo_pools; ++cp)
18727 {
18728 3 int32_t num_combos_in_pool = 0;
18729
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetl(&num_combos_in_pool,f,true))
18730 {
18731 return qe_invalid;
18732 }
18733
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(num_combos_in_pool < 1) continue; //nothing to read
18734
18735
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 temp_cpool.clear();
18736
18737 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18738
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 for(auto q = 0; q < num_combos_in_pool; ++q)
18739 {
18740
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetl(&cp_cid,f,true))
18741 {
18742 return qe_invalid;
18743 }
18744
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&cp_cs,f,true))
18745 {
18746 return qe_invalid;
18747 }
18748
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&cp_quant,f,true))
18749 {
18750 return qe_invalid;
18751 }
18752
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18753 13 }
18754
18755
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(keepdata)
18756 {
18757
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 combo_pools[cp] = temp_cpool;
18758 3 }
18759 3 }
18760
18761 25 return 0;
18762 25 }
18763
18764 25 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18765 {
18766 //these are here to bypass compiler warnings about unused arguments
18767
18768 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18769 //Capitalized cause it'll save you a headache. -Deedee
18770 25 start_cset=start_cset;
18771 25 max_csets=max_csets;
18772 25 word s_version=0;
18773
18774 miscQdata temp_misc;
18775 25 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18776
18777 byte temp_colordata[48];
18778 char temp_palname[PALNAMESIZE];
18779
18780 int32_t dummy;
18781 word palcycles;
18782
18783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(version > 0x192)
18784 {
18785 //section version info
18786
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
18787 {
18788 return qe_invalid;
18789 }
18790
18791 25 FFCore.quest_format[vCSets] = s_version;
18792
18793 //al_trace("Color data version %d\n", s_version);
18794
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&dummy,f,true))
18795 {
18796 return qe_invalid;
18797 }
18798
18799 //section size
18800
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
18801 {
18802 return qe_invalid;
18803 }
18804 25 }
18805
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if (s_version < 5)
18806 {
18807
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18808
18809 //finally... section data
18810 24 int32_t q = 0;
18811 24 int32_t p = -15;
18812
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 24 times.
5784 for(int32_t i=0; i<oldpdTOTAL; ++i)
18813 {
18814 5760 memset(temp_colordata, 0, 48);
18815
18816
1/2
✓ Branch 0 taken 5760 times.
✗ Branch 1 not taken.
5760 if(!pfread(temp_colordata,48,f,true))
18817 {
18818 return qe_invalid;
18819 }
18820
18821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5760 times.
5760 if(keepdata==true)
18822 {
18823 5760 memcpy(&colordata[q*48], temp_colordata, 48);
18824 5760 }
18825 5760 ++q;
18826
7/8
✓ Branch 0 taken 5376 times.
✓ Branch 1 taken 384 times.
✓ Branch 2 taken 408 times.
✓ Branch 3 taken 4968 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 360 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 48 times.
5760 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18827 {
18828
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if (s_version < 5) //Bumping up the size of level palettes
18829 {
18830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(keepdata==true)
18831 {
18832 408 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18833 408 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18834 408 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18835 408 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18836 408 }
18837 408 q+=4;
18838 408 }
18839 else
18840 {
18841 for(int m = 0; m < 4; ++m)
18842 {
18843 memset(temp_colordata, 0, 48);
18844 if(!pfread(temp_colordata,48,f,true))
18845 {
18846 return qe_invalid;
18847 }
18848 if(keepdata==true)
18849 {
18850 memcpy(&colordata[q*48], temp_colordata, 48);
18851 }
18852 ++q;
18853 }
18854 }
18855 408 }
18856 5760 ++p;
18857 5760 }
18858
18859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(RealOldVerion)
18860 {
18861 if(keepdata==true)
18862 {
18863 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18864 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18865 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18866 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18867 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18868 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18869 }
18870 }
18871 else
18872 {
18873 24 memset(temp_colordata, 0, 48);
18874
18875
2/2
✓ Branch 0 taken 75192 times.
✓ Branch 1 taken 24 times.
75216 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18876 {
18877
1/2
✓ Branch 0 taken 75192 times.
✗ Branch 1 not taken.
75192 if(!pfread(temp_colordata,48,f,true))
18878 {
18879 return qe_invalid;
18880 }
18881
18882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75192 times.
75192 if(keepdata==true)
18883 {
18884 75192 memcpy(&colordata[q*48], temp_colordata, 48);
18885 75192 }
18886 75192 ++q;
18887
6/8
✓ Branch 0 taken 75192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✓ Branch 3 taken 69408 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 5736 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
75192 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18888 {
18889
1/2
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
5784 if (s_version < 5) //Bumping up the size of level palettes
18890 {
18891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5784 times.
5784 if(keepdata==true)
18892 {
18893 5784 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18894 5784 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18895 5784 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18896 5784 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18897 5784 }
18898 5784 q+=4;
18899 5784 }
18900 else
18901 {
18902 for(int m = 0; m < 4; ++m)
18903 {
18904 memset(temp_colordata, 0, 48);
18905 if(!pfread(temp_colordata,48,f,true))
18906 {
18907 return qe_invalid;
18908 }
18909 if(keepdata==true)
18910 {
18911 memcpy(&colordata[q*48], temp_colordata, 48);
18912 }
18913 ++q;
18914 }
18915 }
18916 5784 }
18917 75192 ++p;
18918 75192 }
18919
18920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(s_version < 4)
18921 {
18922 if(keepdata==true)
18923 {
18924 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18925 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18926 }
18927 }
18928 else
18929 {
18930
2/2
✓ Branch 0 taken 79872 times.
✓ Branch 1 taken 24 times.
79896 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18931 {
18932
1/2
✓ Branch 0 taken 79872 times.
✗ Branch 1 not taken.
79872 if(!pfread(temp_colordata,48,f,true))
18933 {
18934 return qe_invalid;
18935 }
18936
18937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79872 times.
79872 if(keepdata==true)
18938 {
18939 79872 memcpy(&colordata[q*48], temp_colordata, 48);
18940 79872 }
18941 79872 ++q;
18942
5/6
✓ Branch 0 taken 79872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6144 times.
✓ Branch 3 taken 73728 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 6096 times.
79872 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18943 {
18944
1/2
✓ Branch 0 taken 6096 times.
✗ Branch 1 not taken.
6096 if (s_version < 5) //Bumping up the size of level palettes
18945 {
18946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6096 times.
6096 if(keepdata==true)
18947 {
18948 6096 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18949 6096 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18950 6096 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18951 6096 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18952 6096 }
18953 6096 q+=4;
18954 6096 }
18955 else
18956 {
18957 for(int m = 0; m < 4; ++m)
18958 {
18959 memset(temp_colordata, 0, 48);
18960 if(!pfread(temp_colordata,48,f,true))
18961 {
18962 return qe_invalid;
18963 }
18964 if(keepdata==true)
18965 {
18966 memcpy(&colordata[q*48], temp_colordata, 48);
18967 }
18968 ++q;
18969 }
18970 }
18971 6096 }
18972 79872 ++p;
18973 79872 }
18974
18975 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18976 }
18977 }
18978 24 }
18979 else
18980 {
18981
2/2
✓ Branch 0 taken 8749 times.
✓ Branch 1 taken 1 times.
8750 for(int32_t i=0; i<pdTOTAL255; ++i)
18982 {
18983 8749 memset(temp_colordata, 0, 48);
18984
18985
1/2
✓ Branch 0 taken 8749 times.
✗ Branch 1 not taken.
8749 if(!pfread(temp_colordata,48,f,true))
18986 {
18987 return qe_invalid;
18988 }
18989
18990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8749 times.
8749 if(keepdata==true)
18991 {
18992 8749 memcpy(&colordata[i*48], temp_colordata, 48);
18993 8749 }
18994 8749 }
18995 }
18996
18997
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((version < 0x192)||((version == 0x192)&&(build<76)))
18998 {
18999 if(keepdata==true)
19000 {
19001 init_palnames();
19002 }
19003 }
19004 else
19005 {
19006 25 int32_t palnamestoread = 0;
19007
19008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version < 3)
19009 palnamestoread = OLDMAXLEVELS;
19010 else
19011 25 palnamestoread = 512;
19012
19013
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<palnamestoread; ++i)
19014 {
19015 12800 memset(temp_palname, 0, PALNAMESIZE);
19016
19017
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19018 {
19019 return qe_invalid;
19020 }
19021
19022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(keepdata==true)
19023 {
19024 12800 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19025 12800 }
19026 12800 }
19027
19028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
19029 {
19030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19031 {
19032 memset(palnames[i], 0, PALNAMESIZE);
19033 }
19034 25 }
19035 }
19036
19037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(version > 0x192)
19038 {
19039
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<256; i++)
19040 {
19041
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 for(int32_t j=0; j<3; j++)
19042 {
19043 19200 temp_misc.cycles[i][j].first=0;
19044 19200 temp_misc.cycles[i][j].count=0;
19045 19200 temp_misc.cycles[i][j].speed=0;
19046 19200 }
19047 6400 }
19048
19049
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&palcycles,f,true))
19050 {
19051 return qe_invalid;
19052 }
19053
19054
2/2
✓ Branch 0 taken 806 times.
✓ Branch 1 taken 25 times.
831 for(int32_t i=0; i<palcycles; i++)
19055 {
19056
2/2
✓ Branch 0 taken 2418 times.
✓ Branch 1 taken 806 times.
3224 for(int32_t j=0; j<3; j++)
19057 {
19058
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19059 {
19060 return qe_invalid;
19061 }
19062 2418 }
19063
19064
2/2
✓ Branch 0 taken 2418 times.
✓ Branch 1 taken 806 times.
3224 for(int32_t j=0; j<3; j++)
19065 {
19066
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19067 {
19068 return qe_invalid;
19069 }
19070 2418 }
19071
19072
2/2
✓ Branch 0 taken 2418 times.
✓ Branch 1 taken 806 times.
3224 for(int32_t j=0; j<3; j++)
19073 {
19074
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19075 {
19076 return qe_invalid;
19077 }
19078 2418 }
19079 806 }
19080
19081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
19082 {
19083 25 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19084 25 }
19085 25 }
19086
19087 25 return 0;
19088 25 }
19089
19090 25 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19091 {
19092 25 int32_t tiles_used=0;
19093 25 word section_version = 0;
19094 25 word section_cversion = 0;
19095 25 int32_t section_size= 0;
19096 25 byte *temp_tile = new byte[tilesize(tf32Bit)];
19097
19098 //Tile Expansion
19099 //if ( version >= 0x254 && build >= 41 )
19100
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
25 if (version < 0x254 && build < 41)
19101 {
19102 //al_trace("Build was < 41 when reading tiles\n");
19103 24 max_tiles = ZC250MAXTILES;
19104 24 }
19105
19106 //al_trace("Max Tiles: %d\n", max_tiles);
19107
19108
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19109 {
19110 if(keepdata==true)
19111 {
19112 if(!init_tiles(true, Header))
19113 {
19114 al_trace("Unable to initialize tiles\n");
19115 }
19116 }
19117
19118 delete[] temp_tile;
19119 temp_tile=NULL;
19120 return 0;
19121 }
19122 else
19123 {
19124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(version > 0x192)
19125 {
19126 //section version info
19127
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&section_version,f,true))
19128 {
19129 delete[] temp_tile;
19130 return qe_invalid;
19131 }
19132
19133 25 FFCore.quest_format[vTiles] = section_version;
19134
19135
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&section_cversion,f,true))
19136 {
19137 delete[] temp_tile;
19138 return qe_invalid;
19139 }
19140
19141 //section size
19142
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&section_size,f,true))
19143 {
19144 delete[] temp_tile;
19145 return qe_invalid;
19146 }
19147 25 }
19148
19149 //if ( build < 41 )
19150 //{
19151 // tiles_used = ZC250MAXTILES;
19152 //}
19153
19154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(version < 0x174)
19155 {
19156 tiles_used=TILES_PER_PAGE*4;
19157 } //no expanded tile space
19158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 else if(version < 0x191)
19159 {
19160 tiles_used=OLDMAXTILES;
19161 }
19162 else
19163 {
19164 //finally... section data
19165
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
25 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19166 {
19167
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&tiles_used,f,true))
19168 {
19169 delete[] temp_tile;
19170 return qe_invalid;
19171 }
19172 1 }
19173 else
19174 {
19175
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tiles_used,f,true))
19176 {
19177 delete[] temp_tile;
19178 return qe_invalid;
19179 }
19180 }
19181 }
19182
19183
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 tiles_used=zc_min(tiles_used, max_tiles);
19184
19185 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19186 //if ( version < 0x254 && build < 41 )
19187
3/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if ( version < 0x254 || (version == 0x254 && build < 41) )
19188 //if ( build < 41 )
19189 {
19190
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19191 24 }
19192 else //2.55
19193 {
19194
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19195 }
19196
19197 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19198
19199 //al_trace("tiles_used = %d\n", tiles_used);
19200
19201
2/2
✓ Branch 0 taken 246578 times.
✓ Branch 1 taken 25 times.
246603 for(int32_t i=0; i<tiles_used; ++i)
19202 {
19203 246578 byte format=tf4Bit;
19204 246578 memset(temp_tile, 0, tilesize(tf32Bit));
19205
19206
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 246578 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
246578 if((version>0x211)||((version==0x211)&&(build>4)))
19207 {
19208
1/2
✓ Branch 0 taken 246578 times.
✗ Branch 1 not taken.
246578 if(!p_getc(&format,f,true))
19209 {
19210 delete[] temp_tile;
19211 return qe_invalid;
19212 }
19213 246578 }
19214
4/4
✓ Branch 0 taken 35078 times.
✓ Branch 1 taken 211500 times.
✓ Branch 2 taken 17399 times.
✓ Branch 3 taken 17679 times.
246578 if(section_version > 2 && !format)
19215 {
19216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17679 times.
17679 if(keepdata)
19217 {
19218 17679 reset_tile(buf,start_tile+i,tf4Bit);
19219 17679 }
19220 17679 continue;
19221 }
19222
19223
1/2
✓ Branch 0 taken 228899 times.
✗ Branch 1 not taken.
228899 if(!pfread(temp_tile,tilesize(format),f,true))
19224 {
19225 delete[] temp_tile;
19226 return qe_invalid;
19227 }
19228
19229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228899 times.
228899 if(keepdata==true)
19230 {
19231 228899 buf[start_tile+i].format=format;
19232
19233
1/2
✓ Branch 0 taken 228899 times.
✗ Branch 1 not taken.
228899 if(buf[start_tile+i].data)
19234 {
19235 228899 free(buf[start_tile+i].data);
19236 228899 buf[start_tile+i].data=NULL;
19237 228899 }
19238
19239 228899 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19240 228899 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19241 228899 }
19242 228899 }
19243 }
19244
19245
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19246 {
19247 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19248
2/2
✓ Branch 0 taken 3575520 times.
✓ Branch 1 taken 24 times.
3575544 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19249 {
19250
19251 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19252 3575520 reset_tile(buf,q,tf4Bit);
19253
19254
19255 /*
19256
19257 byte tempbyte;
19258 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19259 {
19260 tempbyte=buf[ZC250MAXTILES-1].data[i];
19261 buf[q].data[i] = tempbyte;
19262 }
19263 //int32_t temp = tempbyte=buf[130].data[i];
19264 //buf[q].data = buf[ZC250MAXTILES-1].data;
19265 */
19266 //reset_tile(buf,q,tf4Bit);
19267 3575520 }
19268
19269 24 }
19270
19271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
19272 {
19273
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
25 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19274 {
19275
2/2
✓ Branch 0 taken 1360980 times.
✓ Branch 1 taken 24 times.
1361004 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19276 {
19277 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19278 1360980 reset_tile(buf,i,tf4Bit);
19279 1360980 }
19280 24 }
19281 else
19282 {
19283
2/2
✓ Branch 0 taken 179422 times.
✓ Branch 1 taken 1 times.
179423 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19284 {
19285 //al_trace("Resetting tiles for build 41+\n");
19286 179422 reset_tile(buf,i,tf4Bit);
19287 179422 }
19288 }
19289
19290
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19291 {
19292 if(get_bit(quest_rules,qr_BSZELDA)) //
19293 {
19294 byte tempbyte;
19295 int32_t floattile=wpnsbuf[iwSwim].tile;
19296
19297 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19298 {
19299 tempbyte=buf[23].data[i];
19300 buf[23].data[i]=buf[24].data[i];
19301 buf[24].data[i]=buf[25].data[i];
19302 buf[25].data[i]=buf[26].data[i];
19303 buf[26].data[i]=tempbyte;
19304 }
19305 //swim tiles are out of order, too, but nobody cared? -Z
19306 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19307 {
19308 tempbyte=buf[floattile+11].data[i];
19309 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19310 buf[floattile+12].data[i]=tempbyte;
19311 }
19312 }
19313 }
19314
19315
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19316 {
19317 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19318 {
19319 byte tempbyte;
19320
19321 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19322 {
19323 tempbyte=buf[130].data[i];
19324 buf[130].data[i]=buf[132].data[i];
19325 buf[132].data[i]=tempbyte;
19326
19327 tempbyte=buf[131].data[i];
19328 buf[131].data[i]=buf[133].data[i];
19329 buf[133].data[i]=tempbyte;
19330 }
19331 }
19332 }
19333
19334 25 al_trace("Registering blank tiles\n");
19335 25 register_blank_tiles();
19336 25 }
19337
19338 //memset(temp_tile, 0, tilesize(tf32Bit));
19339
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 delete[] temp_tile;
19340 25 temp_tile=NULL;
19341 25 return 0;
19342 25 }
19343
19344 25 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19345 {
19346 25 byte *mf=midi_flags;
19347 int32_t dummy;
19348 word dummy2;
19349 // zcmidi_ temp_midi;
19350 int32_t tunes_to_read;
19351 25 int32_t tune_count=0;
19352 25 word section_version=0;
19353 25 zctune temp;
19354
19355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version < 0x193)
19356 {
19357 // mf=Header->data_flags+ZQ_MIDIS2;
19358 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19359 {
19360 tunes_to_read=MAXCUSTOMMIDIS192b177;
19361 }
19362 else
19363 {
19364 tunes_to_read=MAXCUSTOMTUNES;
19365 }
19366 }
19367 else
19368 {
19369 //section version info
19370
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&section_version,f,true))
19371 {
19372 return qe_invalid;
19373 }
19374
19375 25 FFCore.quest_format[vMIDIs] = section_version;
19376
19377 //al_trace("Tunes version %d\n", section_version);
19378
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&dummy2,f,true))
19379 {
19380 return qe_invalid;
19381 }
19382
19383 //section size
19384
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
19385 {
19386 return qe_invalid;
19387 }
19388
19389 //finally... section data
19390
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19391 {
19392 return qe_invalid;
19393 }
19394
19395 25 tunes_to_read=MAXCUSTOMTUNES;
19396 }
19397
19398
2/2
✓ Branch 0 taken 6300 times.
✓ Branch 1 taken 25 times.
6325 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19399 {
19400
2/2
✓ Branch 0 taken 5927 times.
✓ Branch 1 taken 373 times.
6300 if(get_bit(mf, i))
19401 {
19402 373 ++tune_count;
19403 373 }
19404 6300 }
19405
19406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
19407 {
19408 25 reset_tunes(tunes); //reset_midis(midis);
19409 25 }
19410
19411
2/2
✓ Branch 0 taken 6300 times.
✓ Branch 1 taken 25 times.
6325 for(int32_t i=0; i<tunes_to_read; i++)
19412 {
19413 6300 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19414
19415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6300 times.
6300 if(keepdata==true)
19416 {
19417 6300 tunes[i].reset(); // reset_midi(midis+i);
19418 6300 }
19419
19420
2/2
✓ Branch 0 taken 5927 times.
✓ Branch 1 taken 373 times.
6300 if(get_bit(mf,i))
19421 {
19422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 if(section_version < 4)
19423 {
19424 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19425 {
19426 return qe_invalid;
19427 }
19428 }
19429 else
19430 {
19431
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19432 {
19433 return qe_invalid;
19434 }
19435 }
19436
19437
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(!p_igetl(&temp.start,f,true))
19438 {
19439 return qe_invalid;
19440 }
19441
19442
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(!p_igetl(&temp.loop_start,f,true))
19443 {
19444 return qe_invalid;
19445 }
19446
19447
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(!p_igetl(&temp.loop_end,f,true))
19448 {
19449 return qe_invalid;
19450 }
19451
19452
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(!p_igetw(&temp.loop,f,true))
19453 {
19454 return qe_invalid;
19455 }
19456
19457
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(!p_igetw(&temp.volume,f,true))
19458 {
19459 return qe_invalid;
19460 }
19461
19462
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(Header->zelda_version < 0x193)
19463 {
19464 if(!p_igetl(&dummy,f,true))
19465 {
19466 return qe_invalid;
19467 }
19468 }
19469
19470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 if(section_version >= 3)
19471 {
19472
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19473 {
19474 return qe_invalid;
19475 }
19476 373 }
19477
19478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 if(keepdata==true)
19479 {
19480 373 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19481 373 }
19482
19483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19484 {
19485 // old format - a midi is a midi
19486 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19487 {
19488 return qe_invalid;
19489 }
19490
19491 //yes you can do this. Isn't the ? operator awesome? :)
19492 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19493 }
19494 else
19495 {
19496 // 'midi' could be midi or nes, gb, ... music
19497
2/4
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 373 times.
✗ Branch 3 not taken.
373 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19498 {
19499 return qe_invalid;
19500 }
19501
19502
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19503
19504
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 switch(temp.format)
19505 {
19506 case MFORMAT_MIDI:
19507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 if((ptr->data=read_midi(f, true))==NULL)
19508 {
19509 return qe_invalid;
19510 }
19511
19512 373 break;
19513
19514 default:
19515 return qe_invalid;
19516 break;
19517 }
19518 }
19519 373 }
19520 6300 }
19521
19522 25 return 0;
19523 25 }
19524
19525 25 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19526 {
19527 int32_t dummy;
19528 ZCHEATS tempzcheats;
19529 25 char temp_use_cheats=1;
19530 25 memset(&tempzcheats, 0, sizeof(tempzcheats));
19531 25 word s_version = 0;
19532
19533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version > 0x192)
19534 {
19535 //section version info
19536
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
19537 {
19538 return qe_invalid;
19539 }
19540
19541 25 FFCore.quest_format[vCheats] = s_version;
19542 //al_trace("Cheats version %d\n", dummy);
19543
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&dummy,f,true))
19544 {
19545 return qe_invalid;
19546 }
19547
19548 //section size
19549
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
19550 {
19551 return qe_invalid;
19552 }
19553
19554 //finally... section data
19555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_getc(&temp_use_cheats,f,true))
19556 {
19557 return qe_invalid;
19558 }
19559 25 }
19560
19561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->data_flags[ZQ_CHEATS2])
19562 {
19563
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempzcheats.flags,f,true))
19564 {
19565 return qe_invalid;
19566 }
19567
19568
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19569 {
19570 return qe_invalid;
19571 }
19572 25 }
19573
19574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
19575 {
19576 25 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19577 25 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19578 25 }
19579
19580 25 return 0;
19581 25 }
19582
19583 25 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19584 {
19585 int32_t dummy;
19586 25 word s_version=0, s_cversion=0;
19587 byte padding;
19588
19589 zinitdata temp_zinit;
19590 25 memset(&temp_zinit, 0, sizeof(zinitdata));
19591
19592
19593 // Legacy item properties (now integrated into itemdata)
19594 byte sword_hearts[4];
19595 byte beam_hearts[4];
19596 25 byte beam_percent=0;
19597 word beam_power[4];
19598 25 byte hookshot_length=99;
19599 25 byte hookshot_links=100;
19600 25 byte longshot_length=99;
19601 25 byte longshot_links=100;
19602 25 byte moving_fairy_hearts=3;
19603 25 byte moving_fairy_heart_percent=0;
19604 25 byte stationary_fairy_hearts=3;
19605 25 byte stationary_fairy_heart_percent=0;
19606 25 byte moving_fairy_magic=0;
19607 25 byte moving_fairy_magic_percent=0;
19608 25 byte stationary_fairy_magic=0;
19609 25 byte stationary_fairy_magic_percent=0;
19610 25 byte blue_potion_hearts=100;
19611 25 byte blue_potion_heart_percent=1;
19612 25 byte red_potion_hearts=100;
19613 25 byte red_potion_heart_percent=1;
19614 25 byte blue_potion_magic=100;
19615 25 byte blue_potion_magic_percent=1;
19616 25 byte red_potion_magic=100;
19617 25 byte red_potion_magic_percent=1;
19618
19619 25 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19620 25 temp_zinit.max_rupees=255;
19621 25 temp_zinit.max_keys=255;
19622 25 temp_zinit.hcp_per_hc=4;
19623 25 temp_zinit.bomb_ratio=4;
19624
19625
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<MAXITEMS; i++)
19626 {
19627 6400 temp_zinit.items[i]=false;
19628 6400 }
19629
19630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Header->zelda_version > 0x192)
19631 {
19632 //section version info
19633
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
19634 {
19635 return qe_invalid;
19636 }
19637
19638 25 FFCore.quest_format[vInitData] = s_version;
19639
19640 //al_trace("Init data version %d\n", s_version);
19641
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
19642 {
19643 return qe_invalid;
19644 }
19645
19646 //section size
19647
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy,f,true))
19648 {
19649 return qe_invalid;
19650 }
19651 25 }
19652
19653 /* HIGHLY UNORTHODOX UPDATING THING, by L
19654 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19655 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19656 * changing from 13 to 14.
19657 */
19658
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(keepdata && s_version < 14)
19659 fixpolsvoice=true;
19660
19661 /* End highly unorthodox updating thing */
19662
19663 25 temp_zinit.ss_grid_x=8;
19664 25 temp_zinit.ss_grid_y=8;
19665 25 temp_zinit.ss_grid_xofs=0;
19666 25 temp_zinit.ss_grid_yofs=0;
19667 25 temp_zinit.ss_grid_color=8;
19668 25 temp_zinit.ss_bbox_1_color=15;
19669 25 temp_zinit.ss_bbox_2_color=7;
19670 25 temp_zinit.ss_flags=0;
19671 25 temp_zinit.gravity=16;
19672 25 temp_zinit.terminalv=320;
19673 25 temp_zinit.msg_speed=5;
19674 25 temp_zinit.transition_type=0;
19675 25 temp_zinit.jump_hero_layer_threshold=255;
19676 25 temp_zinit.subscrSpeed = 1;
19677
19678
3/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1 times.
25 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19679 1 temp_zinit.jump_hero_layer_threshold=0;
19680
19681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version >= 10)
19682 {
19683 char temp;
19684
19685 //new-style items
19686
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t j=0; j<256; j++)
19687 {
19688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_getc(&temp,f,true))
19689 return qe_invalid;
19690
19691 6400 temp_zinit.items[j] = (temp != 0);
19692 6400 }
19693 25 }
19694
19695
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19696 {
19697 char temp;
19698
19699 //finally... section data
19700
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if((Header->zelda_version > 0x192)||
19701 //new only
19702 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19703 {
19704 //OLD-style items... sigh
19705
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version < 10)
19706 {
19707 if(!p_getc(&temp,f,true))
19708 {
19709 return qe_invalid;
19710 }
19711
19712 temp_zinit.items[iRaft]=(temp != 0);
19713
19714 if(!p_getc(&temp,f,true))
19715 {
19716 return qe_invalid;
19717 }
19718
19719 temp_zinit.items[iLadder]=(temp != 0);
19720
19721 if(!p_getc(&temp,f,true))
19722 {
19723 return qe_invalid;
19724 }
19725
19726 temp_zinit.items[iBook]=(temp != 0);
19727
19728 if(!p_getc(&temp,f,true))
19729 {
19730 return qe_invalid;
19731 }
19732
19733 temp_zinit.items[iMKey]=(temp!=0);
19734
19735 if(!p_getc(&temp,f,true))
19736 {
19737 return qe_invalid;
19738 }
19739
19740 temp_zinit.items[iFlippers]=(temp != 0);
19741
19742 if(!p_getc(&temp,f,true))
19743 {
19744 return qe_invalid;
19745 }
19746
19747 temp_zinit.items[iBoots]=(temp!=0);
19748 }
19749 25 }
19750
19751
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version < 10)
19752 {
19753 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19754
19755 if(!p_getc(&tempring,f,true))
19756 {
19757 return qe_invalid;
19758 }
19759
19760 if(!p_getc(&tempsword,f,true))
19761 {
19762 return qe_invalid;
19763 }
19764
19765 if(!p_getc(&tempshield,f,true))
19766 {
19767 return qe_invalid;
19768 }
19769
19770 if(!p_getc(&tempwallet,f,true))
19771 {
19772 return qe_invalid;
19773 }
19774
19775 if(!p_getc(&tempbracelet,f,true))
19776 {
19777 return qe_invalid;
19778 }
19779
19780 if(!p_getc(&tempamulet,f,true))
19781 {
19782 return qe_invalid;
19783 }
19784
19785 if(!p_getc(&tempbow,f,true))
19786 {
19787 return qe_invalid;
19788 }
19789
19790 //old only
19791 if((Header->zelda_version == 0x192)&&(Header->build<174))
19792 {
19793 tempring=(tempring)?(1<<(tempring-1)):0;
19794 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19795 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19796 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19797 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19798 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19799 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19800 }
19801
19802 //rings start at level 2... wtf
19803 //account for this -DD
19804 tempring <<= 1;
19805 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19806 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19807 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19808 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19809 //bracelet ALSO starts at level 2 :-( -DD
19810 tempbracelet<<=1;
19811 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19812 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19813 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19814
19815 //new only
19816 if((Header->zelda_version == 0x192)&&(Header->build>173))
19817 {
19818 for(int32_t q=0; q<32; q++)
19819 {
19820 if(!p_getc(&padding,f,true))
19821 {
19822 return qe_invalid;
19823 }
19824 }
19825 }
19826
19827 char tempcandle, tempboomerang, temparrow, tempwhistle;
19828
19829 if(!p_getc(&tempcandle,f,true))
19830 {
19831 return qe_invalid;
19832 }
19833
19834 if(!p_getc(&tempboomerang,f,true))
19835 {
19836 return qe_invalid;
19837 }
19838
19839 if(!p_getc(&temparrow,f,true))
19840 {
19841 return qe_invalid;
19842 }
19843
19844 if(!p_getc(&temp,f,true))
19845 {
19846 return qe_invalid;
19847 }
19848
19849 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19850
19851 if(!p_getc(&tempwhistle,f,true))
19852 {
19853 return qe_invalid;
19854 }
19855
19856 //old only
19857 if((Header->zelda_version == 0x192)&&(Header->build<174))
19858 {
19859 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19860 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19861 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19862 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19863 }
19864
19865 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19866 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19867 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19868 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19869 //What about the potion...?
19870
19871 }
19872
19873
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version < 29)
19874 {
19875 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19876 //to jab out my eye...
19877
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f,true))
19878 return qe_invalid;
19879 24 temp_zinit.bombs = padding;
19880
19881
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f,true))
19882 return qe_invalid;
19883 24 temp_zinit.super_bombs = padding;
19884 24 }
19885
19886 //Back to more OLD item code
19887
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version < 10)
19888 {
19889 if((Header->zelda_version > 0x192)||
19890 //new only
19891 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19892 {
19893 if(!p_getc(&temp,f,true))
19894 {
19895 return qe_invalid;
19896 }
19897
19898 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19899
19900 if(!p_getc(&temp,f,true))
19901 {
19902 return qe_invalid;
19903 }
19904
19905 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19906
19907 if(!p_getc(&temp,f,true))
19908 {
19909 return qe_invalid;
19910 }
19911
19912 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19913
19914 if(!p_getc(&temp,f,true))
19915 {
19916 return qe_invalid;
19917 }
19918
19919 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19920
19921 if(!p_getc(&temp,f,true))
19922 {
19923 return qe_invalid;
19924 }
19925
19926 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19927
19928 if(!p_getc(&temp,f,true))
19929 {
19930 return qe_invalid;
19931 }
19932
19933 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19934
19935 if(!p_getc(&temp,f,true))
19936 {
19937 return qe_invalid;
19938 }
19939
19940 addOldStyleFamily(&temp_zinit, itemsbuf, itype_dinsfire, temp);
19941
19942 if(!p_getc(&temp,f,true))
19943 {
19944 return qe_invalid;
19945 }
19946
19947 addOldStyleFamily(&temp_zinit, itemsbuf, itype_faroreswind, temp);
19948
19949 if(!p_getc(&temp,f,true))
19950 {
19951 return qe_invalid;
19952 }
19953
19954 addOldStyleFamily(&temp_zinit, itemsbuf, itype_nayruslove, temp);
19955
19956 if(!p_getc(&temp,f,true))
19957 {
19958 return qe_invalid;
19959 }
19960
19961 if(Header->zelda_version == 0x192)
19962 {
19963 for(int32_t q=0; q<32; q++)
19964 {
19965 if(!p_getc(&padding,f,true))
19966 {
19967 return qe_invalid;
19968 }
19969 }
19970 }
19971 }
19972 }
19973
19974 //old only
19975
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if((Header->zelda_version == 0x192)&&(Header->build<174))
19976 {
19977 byte equipment, items; //bit flags
19978
19979 if(!p_getc(&equipment,f,true))
19980 {
19981 return qe_invalid;
19982 }
19983
19984 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19985 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19986 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19987 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19988 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19989 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19990
19991
19992 if(!p_getc(&items,f,true))
19993 {
19994 return qe_invalid;
19995 }
19996
19997 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19998 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19999 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
20000 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
20001 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
20002 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
20003 }
20004
20005
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.hc,f,true))
20006 {
20007 return qe_invalid;
20008 }
20009
20010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version < 14)
20011 {
20012 byte temphp;
20013
20014 if(!p_getc(&temphp,f,true))
20015 {
20016 return qe_invalid;
20017 }
20018
20019 temp_zinit.start_heart=temphp;
20020
20021 if(!p_getc(&temphp,f,true))
20022 {
20023 return qe_invalid;
20024 }
20025
20026 temp_zinit.cont_heart=temphp;
20027 }
20028 else
20029 {
20030
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.start_heart,f,true))
20031 {
20032 return qe_invalid;
20033 }
20034
20035
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20036 {
20037 return qe_invalid;
20038 }
20039 }
20040
20041
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.hcp,f,true))
20042 {
20043 return qe_invalid;
20044 }
20045
20046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version >= 14)
20047 {
20048
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20049 {
20050 return qe_invalid;
20051 }
20052
20053
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version<16) // July 2007
20054 {
20055 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20056 temp_zinit.hcp_per_hc = 0xFF;
20057
20058 //Dispose of legacy rule
20059 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20060 }
20061 25 }
20062
20063
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version < 29)
20064 {
20065
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f,true))
20066 return qe_invalid;
20067 24 temp_zinit.max_bombs = padding;
20068 24 }
20069
20070
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.keys,f,true))
20071 {
20072 return qe_invalid;
20073 }
20074
20075
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.rupies,f,true))
20076 {
20077 return qe_invalid;
20078 }
20079
20080
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.triforce,f,true))
20081 {
20082 return qe_invalid;
20083 }
20084
20085
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20086 {
20087
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 25 times.
1625 for(int32_t i=0; i<64; i++)
20088 {
20089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
1600 if(!p_getc(&temp_zinit.map[i],f,true))
20090 {
20091 return qe_invalid;
20092 }
20093 1600 }
20094
20095
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 25 times.
1625 for(int32_t i=0; i<64; i++)
20096 {
20097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
1600 if(!p_getc(&temp_zinit.compass[i],f,true))
20098 {
20099 return qe_invalid;
20100 }
20101 1600 }
20102 25 }
20103 else
20104 {
20105 for(int32_t i=0; i<32; i++)
20106 {
20107 if(!p_getc(&temp_zinit.map[i],f,true))
20108 {
20109 return qe_invalid;
20110 }
20111 }
20112
20113 for(int32_t i=0; i<32; i++)
20114 {
20115 if(!p_getc(&temp_zinit.compass[i],f,true))
20116 {
20117 return qe_invalid;
20118 }
20119 }
20120 }
20121
20122
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if((Header->zelda_version > 0x192)||
20123 //new only
20124 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20125 {
20126
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20127 {
20128
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 25 times.
1625 for(int32_t i=0; i<64; i++)
20129 {
20130
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20131 {
20132 return qe_invalid;
20133 }
20134 1600 }
20135 25 }
20136 else
20137 {
20138 for(int32_t i=0; i<32; i++)
20139 {
20140 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20141 {
20142 return qe_invalid;
20143 }
20144 }
20145 }
20146 25 }
20147
20148
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 25 times.
425 for(int32_t i=0; i<16; i++)
20149 {
20150
1/2
✓ Branch 0 taken 400 times.
✗ Branch 1 not taken.
400 if(!p_getc(&temp_zinit.misc[i],f,true))
20151 {
20152 return qe_invalid;
20153 }
20154 400 }
20155
20156
1/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if(s_version < 15) for(int32_t i=0; i<4; i++)
20157 {
20158 if(!p_getc(&sword_hearts[i],f,true))
20159 {
20160 return qe_invalid;
20161 }
20162 }
20163
20164
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.last_map,f,true))
20165 {
20166 return qe_invalid;
20167 }
20168
20169
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.last_screen,f,true))
20170 {
20171 return qe_invalid;
20172 }
20173
20174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version < 14)
20175 {
20176 byte tempmp;
20177
20178 if(!p_getc(&tempmp,f,true))
20179 {
20180 return qe_invalid;
20181 }
20182
20183 temp_zinit.max_magic=tempmp;
20184
20185 if(!p_getc(&tempmp,f,true))
20186 {
20187 return qe_invalid;
20188 }
20189
20190 temp_zinit.magic=tempmp;
20191 }
20192 else
20193 {
20194
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.max_magic,f,true))
20195 {
20196 return qe_invalid;
20197 }
20198
20199
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.magic,f,true))
20200 {
20201 return qe_invalid;
20202 }
20203 }
20204
20205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version < 15)
20206 {
20207 if(s_version < 12)
20208 {
20209 temp_zinit.max_magic*=32;
20210 temp_zinit.magic*=32;
20211 }
20212
20213 for(int32_t i=0; i<4; i++)
20214 {
20215 if(!p_getc(&beam_hearts[i],f,true))
20216 {
20217 return qe_invalid;
20218 }
20219 }
20220
20221 if(!p_getc(&beam_percent,f,true))
20222 {
20223 return qe_invalid;
20224 }
20225 }
20226 else
20227 {
20228
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20229 {
20230 return qe_invalid;
20231 }
20232 }
20233
20234
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version < 15)
20235 {
20236 byte tempbp;
20237
20238 for(int32_t i=0; i<4; i++)
20239 {
20240 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20241 {
20242 return qe_invalid;
20243 }
20244
20245 beam_power[i]=tempbp;
20246 }
20247
20248 if(!p_getc(&hookshot_links,f,true))
20249 {
20250 return qe_invalid;
20251 }
20252
20253 if(s_version>6)
20254 {
20255 if(!p_getc(&hookshot_length,f,true))
20256 {
20257 return qe_invalid;
20258 }
20259
20260 if(!p_getc(&longshot_links,f,true))
20261 {
20262 return qe_invalid;
20263 }
20264
20265 if(!p_getc(&longshot_length,f,true))
20266 {
20267 return qe_invalid;
20268 }
20269 }
20270 }
20271
20272
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20273 {
20274 return qe_invalid;
20275 }
20276
20277
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20278 {
20279 return qe_invalid;
20280 }
20281
20282
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.subscreen,f,true))
20283 {
20284 return qe_invalid;
20285 }
20286
20287 //old only
20288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if((Header->zelda_version == 0x192)&&(Header->build<174))
20289 {
20290 for(int32_t i=0; i<32; i++)
20291 {
20292 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20293 {
20294 return qe_invalid;
20295 }
20296 }
20297 }
20298
20299
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20300 {
20301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version <= 10)
20302 {
20303 byte tempbyte;
20304
20305 if(!p_getc(&tempbyte,f,true))
20306 {
20307 return qe_invalid;
20308 }
20309
20310 temp_zinit.start_dmap = (word)tempbyte;
20311 }
20312 else
20313 {
20314
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20315 {
20316 return qe_invalid;
20317 }
20318 }
20319
20320
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20321 {
20322 return qe_invalid;
20323 }
20324 25 }
20325
20326
3/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 24 times.
25 if(s_version>1 && s_version < 29)
20327 {
20328
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f,true))
20329 return qe_invalid;
20330 24 temp_zinit.arrows = padding;
20331
20332
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f,true))
20333 return qe_invalid;
20334 24 temp_zinit.max_arrows = padding;
20335 24 }
20336
20337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version>2)
20338 {
20339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version <= 10)
20340 {
20341 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20342 {
20343 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20344 {
20345 return qe_invalid;
20346 }
20347 }
20348 }
20349 else
20350 {
20351
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i=0; i<MAXLEVELS; i++)
20352 {
20353
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20354 {
20355 return qe_invalid;
20356 }
20357 12800 }
20358 }
20359 25 }
20360
20361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version>3)
20362 {
20363
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20364 {
20365 return qe_invalid;
20366 }
20367
20368
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20369 {
20370 return qe_invalid;
20371 }
20372
20373
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20374 {
20375 return qe_invalid;
20376 }
20377
20378
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20379 {
20380 return qe_invalid;
20381 }
20382
20383
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20384 {
20385 return qe_invalid;
20386 }
20387
20388
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20389 {
20390 return qe_invalid;
20391 }
20392
20393
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20394 {
20395 return qe_invalid;
20396 }
20397
20398
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20399 {
20400 return qe_invalid;
20401 }
20402
20403
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20404
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20405 25 }
20406
20407
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(s_version>4 && s_version<15)
20408 {
20409 if(!p_getc(&moving_fairy_hearts,f,true))
20410 {
20411 return qe_invalid;
20412 }
20413
20414 if(!p_getc(&moving_fairy_heart_percent,f,true))
20415 {
20416 return qe_invalid;
20417 }
20418 }
20419
20420
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(s_version>5 && s_version < 10)
20421 {
20422 if(!p_getc(&temp,f,true))
20423 {
20424 return qe_invalid;
20425 }
20426
20427 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20428 }
20429
20430
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(s_version>6 && s_version<15)
20431 {
20432 if(!p_getc(&stationary_fairy_hearts,f,true))
20433 {
20434 return qe_invalid;
20435 }
20436
20437 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20438 {
20439 return qe_invalid;
20440 }
20441
20442 if(!p_getc(&moving_fairy_magic,f,true))
20443 {
20444 return qe_invalid;
20445 }
20446
20447 if(!p_getc(&moving_fairy_magic_percent,f,true))
20448 {
20449 return qe_invalid;
20450 }
20451
20452 if(!p_getc(&stationary_fairy_magic,f,true))
20453 {
20454 return qe_invalid;
20455 }
20456
20457 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20458 {
20459 return qe_invalid;
20460 }
20461
20462 if(!p_getc(&blue_potion_hearts,f,true))
20463 {
20464 return qe_invalid;
20465 }
20466
20467 if(!p_getc(&blue_potion_heart_percent,f,true))
20468 {
20469 return qe_invalid;
20470 }
20471
20472 if(!p_getc(&red_potion_hearts,f,true))
20473 {
20474 return qe_invalid;
20475 }
20476
20477 if(!p_getc(&red_potion_heart_percent,f,true))
20478 {
20479 return qe_invalid;
20480 }
20481
20482 if(!p_getc(&blue_potion_magic,f,true))
20483 {
20484 return qe_invalid;
20485 }
20486
20487 if(!p_getc(&blue_potion_magic_percent,f,true))
20488 {
20489 return qe_invalid;
20490 }
20491
20492 if(!p_getc(&red_potion_magic,f,true))
20493 {
20494 return qe_invalid;
20495 }
20496
20497 if(!p_getc(&red_potion_magic_percent,f,true))
20498 {
20499 return qe_invalid;
20500 }
20501 }
20502
20503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version>6)
20504 {
20505
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20506 {
20507 return qe_invalid;
20508 }
20509 25 }
20510
20511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version>7)
20512 {
20513
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20514 {
20515 return qe_invalid;
20516 }
20517 25 }
20518
20519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version>8)
20520 {
20521
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20522 {
20523 return qe_invalid;
20524 }
20525
20526
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.max_keys,f,true))
20527 {
20528 return qe_invalid;
20529 }
20530 25 }
20531
20532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version>16)
20533 {
20534
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.gravity,f,true))
20535 {
20536 return qe_invalid;
20537 }
20538
20539
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&temp_zinit.terminalv,f,true))
20540 {
20541 return qe_invalid;
20542 }
20543
20544
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.msg_speed,f,true))
20545 {
20546 return qe_invalid;
20547 }
20548
20549
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.transition_type,f,true))
20550 {
20551 return qe_invalid;
20552 }
20553
20554
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20555 {
20556 return qe_invalid;
20557 }
20558 25 }
20559
20560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version>17)
20561 {
20562
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20563 {
20564 return qe_invalid;
20565 }
20566 25 }
20567
20568 //expaned init data for larger values in 2.55
20569
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20570 {
20571
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.bombs,f,true))
20572 {
20573 return qe_invalid;
20574 }
20575
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20576 {
20577 return qe_invalid;
20578 }
20579
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20580 {
20581 return qe_invalid;
20582 }
20583
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20584 {
20585 return qe_invalid;
20586 }
20587
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.arrows,f,true))
20588 {
20589 return qe_invalid;
20590 }
20591
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20592 {
20593 return qe_invalid;
20594 }
20595
20596 1 }
20597
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( s_version >= 20 )
20598 {
20599
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.heroStep,f,true))
20600 {
20601 return qe_invalid;
20602 }
20603 1 }
20604 else
20605 {
20606 24 temp_zinit.heroStep = 150; //1.5 pixels per frame
20607 }
20608
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if ( s_version >= 21 )
20609 {
20610
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20611 {
20612 return qe_invalid;
20613 }
20614 1 }
20615 else
20616 {
20617 24 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20618 }
20619 //old only
20620
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if((Header->zelda_version == 0x192)&&(Header->build<174))
20621 {
20622 byte items2;
20623
20624 if(!p_getc(&items2,f,true))
20625 {
20626 return qe_invalid;
20627 }
20628
20629 temp_zinit.items[iDinsFire]=(get_bit(&items2, idI_DFIRE)!=0);
20630 temp_zinit.items[iFaroresWind]=(get_bit(&items2, idI_FWIND)!=0);
20631 temp_zinit.items[iNayrusLove]=(get_bit(&items2, idI_NLOVE)!=0);
20632 }
20633
20634
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x193)
20635 {
20636 for(int32_t q=0; q<96; q++)
20637 {
20638 if(!p_getc(&padding,f,true))
20639 {
20640 return qe_invalid;
20641 }
20642 }
20643
20644 //new only
20645 if((Header->zelda_version == 0x192)&&(Header->build>173))
20646 {
20647 if(!p_getc(&padding,f,true))
20648 {
20649 return qe_invalid;
20650 }
20651
20652 if(!p_getc(&padding,f,true))
20653 {
20654 return qe_invalid;
20655 }
20656 }
20657 }
20658 25 }
20659
20660
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20661 {
20662 //temp_zinit.shield=i_smallshield;
20663 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20664
20665 if(sshieldid != -1)
20666 temp_zinit.items[sshieldid] = true;
20667 }
20668
20669
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20670 {
20671 temp_zinit.hc=3;
20672 temp_zinit.start_heart=3;
20673 temp_zinit.cont_heart=3;
20674 temp_zinit.max_bombs=8;
20675 }
20676
20677
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20678 {
20679 sword_hearts[0]=0;
20680 sword_hearts[1]=5;
20681 sword_hearts[2]=12;
20682 sword_hearts[3]=21;
20683 }
20684
20685
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20686 {
20687 temp_zinit.last_map=0;
20688 temp_zinit.last_screen=0;
20689 }
20690
20691
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20692 {
20693 temp_zinit.max_magic=0;
20694 temp_zinit.magic=0;
20695 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20696 }
20697
20698
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20699 {
20700
20701 for(int32_t x=0; x<4; x++)
20702 {
20703 beam_hearts[x]=100;
20704 }
20705
20706 for(int32_t i=0; i<idBP_MAX; i++)
20707 {
20708 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20709 set_bit(quest_rules,qr_LENSHINTS+i,0);
20710 }
20711
20712 for(int32_t x=0; x<4; x++)
20713 {
20714 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20715 }
20716
20717 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20718 hookshot_links=100;
20719 temp_zinit.msg_more_x=224;
20720 temp_zinit.msg_more_y=64;
20721 }
20722
20723 // Okay, let's put these legacy values into itemsbuf.
20724
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(s_version < 15)
20725 for(int32_t i=0; i<MAXITEMS; i++)
20726 {
20727 switch(i)
20728 {
20729 case iFairyStill:
20730 itemsbuf[i].misc1 = stationary_fairy_hearts;
20731 itemsbuf[i].misc2 = stationary_fairy_magic;
20732 itemsbuf[i].misc3 = 0;
20733 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20734 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20735 break;
20736
20737 case iFairyMoving:
20738 itemsbuf[i].misc1 = moving_fairy_hearts;
20739 itemsbuf[i].misc2 = moving_fairy_magic;
20740 itemsbuf[i].misc3 = 50;
20741 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20742 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20743 break;
20744
20745 case iRPotion:
20746 itemsbuf[i].misc1 = red_potion_hearts;
20747 itemsbuf[i].misc2 = red_potion_magic;
20748 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20749 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20750 break;
20751
20752 case iBPotion:
20753 itemsbuf[i].misc1 = blue_potion_hearts;
20754 itemsbuf[i].misc2 = blue_potion_magic;
20755 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20756 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20757 break;
20758
20759 case iSword:
20760 itemsbuf[i].pickup_hearts = sword_hearts[0];
20761 itemsbuf[i].misc1 = beam_hearts[0];
20762 itemsbuf[i].misc2 = beam_power[0];
20763 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20764 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20765 break;
20766
20767 case iWSword:
20768 itemsbuf[i].pickup_hearts = sword_hearts[1];
20769 itemsbuf[i].misc1 = beam_hearts[1];
20770 itemsbuf[i].misc2 = beam_power[1];
20771 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20772 break;
20773
20774 case iMSword:
20775 itemsbuf[i].pickup_hearts = sword_hearts[2];
20776 itemsbuf[i].misc1 = beam_hearts[2];
20777 itemsbuf[i].misc2 = beam_power[2];
20778 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20779 break;
20780
20781 case iXSword:
20782 itemsbuf[i].pickup_hearts = sword_hearts[3];
20783 itemsbuf[i].misc1 = beam_hearts[3];
20784 itemsbuf[i].misc2 = beam_power[3];
20785 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20786 break;
20787
20788 case iHookshot:
20789 itemsbuf[i].misc1 = hookshot_length;
20790 itemsbuf[i].misc2 = hookshot_links;
20791 break;
20792
20793 case iLongshot:
20794 itemsbuf[i].misc1 = longshot_length;
20795 itemsbuf[i].misc2 = longshot_links;
20796 break;
20797 }
20798 }
20799
20800
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20801 {
20802 //was new subscreen rule
20803 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20804 set_bit(quest_rules,qr_FREEFORM,0);
20805 }
20806
20807
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20808 {
20809 temp_zinit.start_dmap=0;
20810 }
20811
20812
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20813 {
20814 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20815 }
20816
20817
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20818 {
20819 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20820 temp_zinit.max_rupees=999;
20821 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20822 }
20823
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20824 {
20825 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20826 temp_zinit.max_bombs = 8;
20827 }
20828 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20829 //time to ensure that we port all new values properly:
20830
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Header->zelda_version < 0x250)
20831 {
20832 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20833 }
20834
20835
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 21)
20836 {
20837
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20838 {
20839 return qe_invalid;
20840 }
20841
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20842 {
20843 return qe_invalid;
20844 }
20845
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20846 {
20847 return qe_invalid;
20848 }
20849
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20850 {
20851 return qe_invalid;
20852 }
20853 1 }
20854 else
20855 {
20856 24 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20857 24 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20858 24 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20859 24 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20860 }
20861
20862
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 22)
20863 {
20864
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1 times.
26 for(int32_t q = 0; q < 25; ++q)
20865 {
20866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20867 {
20868 return qe_invalid;
20869 }
20870 25 }
20871
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1 times.
26 for(int32_t q = 0; q < 25; ++q)
20872 {
20873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20874 {
20875 return qe_invalid;
20876 }
20877 25 }
20878 1 }
20879 else
20880 {
20881
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 24 times.
624 for(int32_t q = 0; q < 25; ++q)
20882 {
20883 600 temp_zinit.scrcnt[q] = 0;
20884 600 temp_zinit.scrmaxcnt[q] = 0;
20885 600 }
20886 }
20887
20888
20889
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 23)
20890 {
20891
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.dither_type,f,true))
20892 {
20893 return qe_invalid;
20894 }
20895
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.dither_arg,f,true))
20896 {
20897 return qe_invalid;
20898 }
20899
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.dither_percent,f,true))
20900 {
20901 return qe_invalid;
20902 }
20903
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20904 {
20905 return qe_invalid;
20906 }
20907
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20908 {
20909 return qe_invalid;
20910 }
20911 1 }
20912 else
20913 {
20914 24 temp_zinit.dither_type = 0;
20915 24 temp_zinit.dither_arg = 0;
20916 24 temp_zinit.dither_percent = 20;
20917 24 temp_zinit.def_lightrad = 24;
20918 24 temp_zinit.transdark_percent = 0;
20919 }
20920
20921
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 24)
20922 {
20923
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.darkcol,f,true))
20924 {
20925 return qe_invalid;
20926 }
20927 1 }
20928 else
20929 {
20930 24 temp_zinit.darkcol = BLACK;
20931 }
20932
20933
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 25)
20934 {
20935
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_zinit.gravity2,f,true))
20936 {
20937 return qe_invalid;
20938 }
20939
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20940 {
20941 return qe_invalid;
20942 }
20943 1 }
20944 else
20945 {
20946 24 temp_zinit.gravity2 = temp_zinit.gravity*100;
20947 24 temp_zinit.swimgravity = 5;
20948 }
20949
20950
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 26)
20951 {
20952
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20953 {
20954 return qe_invalid;
20955 }
20956
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20957 {
20958 return qe_invalid;
20959 }
20960
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20961 {
20962 return qe_invalid;
20963 }
20964 1 }
20965 else
20966 {
20967 24 temp_zinit.heroSideswimUpStep = 150;
20968 24 temp_zinit.heroSideswimSideStep = 100;
20969 24 temp_zinit.heroSideswimDownStep = 75;
20970 }
20971
20972
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 27)
20973 {
20974
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20975 {
20976 return qe_invalid;
20977 }
20978 1 }
20979 else
20980 {
20981 24 temp_zinit.exitWaterJump = 0;
20982 }
20983
20984
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 29)
20985 {
20986
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20987 {
20988 return qe_invalid;
20989 }
20990 1 }
20991 else
20992 {
20993 24 temp_zinit.bunny_ltm = 0;
20994 }
20995
20996
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 30)
20997 {
20998
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20999 {
21000 return qe_invalid;
21001 }
21002 1 }
21003 else
21004 {
21005 24 temp_zinit.switchhookstyle = 1;
21006 }
21007
21008
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(s_version > 31)
21009 {
21010
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
21011 {
21012 return qe_invalid;
21013 }
21014 1 }
21015 else
21016 {
21017 24 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
21018 24 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
21019 }
21020
21021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata==true)
21022 {
21023 25 memcpy(&zinit, &temp_zinit, sizeof(zinitdata));
21024
21025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(zinit.heroAnimationStyle==las_zelda3slow)
21026 {
21027 hero_animation_speed=2;
21028 }
21029 else
21030 {
21031 25 hero_animation_speed=1;
21032 }
21033 25 }
21034
21035 25 return 0;
21036 25 }
21037
21038 /*
21039 void setupitemdropsets()
21040 {
21041 for(int32_t i=0; i<isMAX; i++)
21042 {
21043 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21044 }
21045 }
21046 */
21047
21048 25 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21049 {
21050 25 build=build; // here to prevent compiler warnings
21051 dword dummy_dword;
21052 25 word item_drop_sets_to_read=0;
21053 item_drop_object tempitemdrop;
21054 25 word s_version=0, s_cversion=0;
21055
21056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
21057 {
21058
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21059 {
21060 6400 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21061 6400 }
21062 25 }
21063
21064
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(version > 0x192)
21065 {
21066 25 item_drop_sets_to_read=0;
21067
21068 //section version info
21069
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_version,f,true))
21070 {
21071 return qe_invalid;
21072 }
21073
21074 25 FFCore.quest_format[vItemDropsets] = s_version;
21075
21076 //al_trace("Item drop sets version %d\n", s_version);
21077
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
21078 {
21079 return qe_invalid;
21080 }
21081
21082 //section size
21083
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy_dword,f,true))
21084 {
21085 return qe_invalid;
21086 }
21087
21088 //finally... section data
21089
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&item_drop_sets_to_read,f,true))
21090 {
21091 return qe_invalid;
21092 }
21093 25 }
21094 else
21095 {
21096 if(keepdata==true)
21097 {
21098 init_item_drop_sets();
21099 }
21100 }
21101
21102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(s_version>=1)
21103 {
21104
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 25 times.
417 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21105 {
21106
1/2
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
392 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21107 {
21108 return qe_invalid;
21109 }
21110
21111
2/2
✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 392 times.
4312 for(int32_t j=0; j<10; ++j)
21112 {
21113
1/2
✓ Branch 0 taken 3920 times.
✗ Branch 1 not taken.
3920 if(!p_igetw(&tempitemdrop.item[j],f,true))
21114 {
21115 return qe_invalid;
21116 }
21117 3920 }
21118
21119
2/2
✓ Branch 0 taken 4312 times.
✓ Branch 1 taken 392 times.
4704 for(int32_t j=0; j<11; ++j)
21120 {
21121
1/2
✓ Branch 0 taken 4312 times.
✗ Branch 1 not taken.
4312 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21122 {
21123 return qe_invalid;
21124 }
21125 4312 }
21126
21127 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21128 // overrides the quest's set #12.
21129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(s_version<2 && i==12)
21130 continue;
21131
21132 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21133
1/4
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(s_version<2) for(int32_t j=0; j<10; ++j)
21134 {
21135 int32_t it = tempitemdrop.item[j];
21136
21137 if((itemsbuf[it].family == itype_rupee
21138 && ((itemsbuf[it].amount)&0xFFF) == 10)
21139 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21140 {
21141 tempitemdrop.chance[j+1]=0;
21142 }
21143 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21144 {
21145 tempitemdrop.chance[j+1]=0;
21146 }
21147
21148 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21149 if(itemsbuf[it].family == itype_misc)
21150 {
21151 // If a non-gameplay item was selected, then item drop was aborted.
21152 // Reflect this by increasing the 'Nothing' chance accordingly.
21153 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21154 tempitemdrop.chance[j+1]=0;
21155 }
21156 }
21157
21158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
392 if(keepdata)
21159 {
21160 392 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21161 392 }
21162 392 }
21163 25 }
21164
21165 25 return 0;
21166 25 }
21167
21168 25 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21169 {
21170 int32_t temp_num;
21171 dword dummy_dword;
21172 word num_favorite_combos;
21173 word num_favorite_combo_aliases;
21174 25 word s_version=0, s_cversion=0;
21175
21176 //section version info
21177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetw(&s_version,f,true))
21178 {
21179 return qe_invalid;
21180 }
21181
21182 25 FFCore.quest_format[vFavourites] = s_version;
21183
21184
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&s_cversion,f,true))
21185 {
21186 return qe_invalid;
21187 }
21188
21189 //section size
21190
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&dummy_dword,f,true))
21191 {
21192 return qe_invalid;
21193 }
21194
21195 //finally... section data
21196
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&num_favorite_combos,f,true))
21197 {
21198 return qe_invalid;
21199 }
21200
21201
2/2
✓ Branch 0 taken 2500 times.
✓ Branch 1 taken 25 times.
2525 for(int32_t i=0; i<num_favorite_combos; i++)
21202 {
21203
1/2
✓ Branch 0 taken 2500 times.
✗ Branch 1 not taken.
2500 if(!p_igetl(&temp_num,f,true))
21204 {
21205 return qe_invalid;
21206 }
21207
21208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2500 times.
2500 if(keepdata)
21209 {
21210 2500 favorite_combos[i]=temp_num;
21211 2500 }
21212 2500 }
21213
21214
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21215 {
21216 return qe_invalid;
21217 }
21218
21219
2/2
✓ Branch 0 taken 2500 times.
✓ Branch 1 taken 25 times.
2525 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21220 {
21221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2500 times.
2500 if(!p_igetl(&temp_num,f,true))
21222 {
21223 return qe_invalid;
21224 }
21225
21226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2500 times.
2500 if(keepdata)
21227 {
21228 2500 favorite_comboaliases[i]=temp_num;
21229 2500 }
21230 2500 }
21231
21232 25 return 0;
21233 25 }
21234
21235 /*
21236 switch (ret) {
21237 case 0:
21238 break;
21239
21240 case qe_invalid:
21241 goto invalid;
21242 break;
21243 default:
21244 pack_fclose(f);
21245 if(!oldquest)
21246 delete_file(tmpfilename);
21247 return ret;
21248 break;
21249 }
21250 */
21251
21252 const char *skip_text[skip_max]=
21253 {
21254 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21255 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21256 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21257 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21258 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21259 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21260 "skip_favorites"
21261 };
21262
21263
21264 void port250QuestRules(){
21265
21266 portCandleRules(); //Candle
21267 portBombRules();
21268
21269 }
21270
21271 void portCandleRules()
21272 {
21273 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21274 //itemdata itemsbuf;
21275 for ( int32_t q = 0; q < MAXITEMS; q++ )
21276 {
21277 if ( itemsbuf[q].family == itype_candle )
21278 {
21279 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21280 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21281 }
21282 }
21283 }
21284
21285 void portBombRules()
21286 {
21287 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21288 //itemdata itemsbuf;
21289 for ( int32_t q = 0; q < MAXITEMS; q++ )
21290 {
21291 if ( itemsbuf[q].family == itype_bomb )
21292 {
21293 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21294 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21295 }
21296 }
21297
21298 }
21299
21300 //Internal function for loadquest wrapper
21301 25 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, const byte *skip_flags, byte printmetadata)
21302 {
21303 25 DMapEditorLastMaptileUsed = 0;
21304 25 combosread=false;
21305 25 mapsread=false;
21306 25 fixffcs=false;
21307
21308
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21309 {
21310 keepall=false;
21311 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,lfont);
21312 }
21313
21314 // show_progress=true;
21315 char tmpfilename[L_tmpnam];
21316 25 temp_name(tmpfilename);
21317 // char percent_done[30];
21318 25 bool catchup=false;
21319 byte tempbyte;
21320 25 word old_map_count=map_count;
21321
21322 25 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21323 25 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21324 25 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21325
21326
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepall==false||get_bit(skip_flags, skip_rules))
21327 {
21328 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21329 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21330 }
21331
21332 25 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21333 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21334
21335
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepall==false||get_bit(skip_flags, skip_midis))
21336 {
21337 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21338 }
21339
21340
21341
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21342 {
21343 25 zScript.clear();
21344 25 globalmap.clear();
21345 25 genericmap.clear();
21346 25 ffcmap.clear();
21347 25 itemmap.clear();
21348 25 npcmap.clear();
21349 25 ewpnmap.clear();
21350 25 lwpnmap.clear();
21351 25 playermap.clear();
21352 25 dmapmap.clear();
21353 25 screenmap.clear();
21354 25 itemspritemap.clear();
21355 25 comboscriptmap.clear();
21356
21357
2/2
✓ Branch 0 taken 12775 times.
✓ Branch 1 taken 25 times.
12800 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21358 {
21359 12775 ffcmap[i].clear();
21360 12775 }
21361
21362 25 globalmap[0].slotname = "Slot 1:";
21363 25 globalmap[0].scriptname = "~Init";
21364 25 globalmap[0].update();
21365
21366
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 25 times.
200 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21367 {
21368 175 globalmap[i].clear();
21369 175 }
21370
21371
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21372 {
21373 6375 itemmap[i].clear();
21374 6375 }
21375
21376 //new script types -- prevent carrying over to a quest that you load after reading them
21377 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21378
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21379 {
21380 6375 npcmap[i].clear();
21381 6375 }
21382
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21383 {
21384 6375 lwpnmap[i].clear();
21385 6375 }
21386
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21387 {
21388 6375 ewpnmap[i].clear();
21389 6375 }
21390
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21391 {
21392 100 playermap[i].clear();
21393 100 }
21394
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21395 {
21396 6375 dmapmap[i].clear();
21397 6375 }
21398
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21399 {
21400 6375 screenmap[i].clear();
21401 6375 }
21402
2/2
✓ Branch 0 taken 6375 times.
✓ Branch 1 taken 25 times.
6400 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21403 {
21404 6375 itemspritemap[i].clear();
21405 6375 }
21406
2/2
✓ Branch 0 taken 12775 times.
✓ Branch 1 taken 25 times.
12800 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21407 {
21408 12775 comboscriptmap[i].clear();
21409 12775 }
21410
2/2
✓ Branch 0 taken 12775 times.
✓ Branch 1 taken 25 times.
12800 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21411 {
21412 12775 genericmap[i].clear();
21413 12775 }
21414
21415 25 reset_scripts();
21416 25 }
21417
21418 zquestheader tempheader;
21419 25 memset(&tempheader, 0, sizeof(zquestheader));
21420 25 zinfo tempzi;
21421 25 tempzi.clear();
21422 25 load_tmp_zi = &tempzi;
21423
21424 // oldquest flag is set when an unencrypted qst file is suspected.
21425 25 bool oldquest = false;
21426 25 int32_t open_error=0;
21427 char deletefilename[1024];
21428 25 PACKFILE *f=open_quest_file(&open_error, filename, deletefilename, compressed, encrypted, show_progress);
21429
21430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!f)
21431 return open_error;
21432 char zinfofilename[2048];
21433 25 replace_extension(zinfofilename, filename, "zinfo", 2047);
21434 25 int32_t ret=0;
21435
21436 //header
21437 25 box_out("Reading Header...");
21438 25 ret=readheader(f, &tempheader, true, printmetadata);
21439
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21440 25 box_out("okay.");
21441 25 box_eol();
21442
21443
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(read_zinfo)
21444 {
21445 1 box_out("Reading ZInfo - ");
21446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 box_out(read_ext_zinfo ? "External..." : "Internal...");
21447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(read_ext_zinfo)
21448 {
21449 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21450 ret=readzinfo(inf, tempzi, tempheader);
21451 if(inf) pack_fclose(inf);
21452 checkstatus(ret);
21453 }
21454 else
21455 {
21456 1 ret=readzinfo(f, tempzi, tempheader);
21457
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21458 }
21459 1 box_out("okay.");
21460 1 box_eol();
21461 1 }
21462
21463
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(tempheader.zelda_version>=0x193)
21464 {
21465 dword section_id;
21466
21467 //section id
21468
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_mgetl(&section_id,f,true))
21469 {
21470 return qe_invalid;
21471 }
21472
21473
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 25 times.
625 while(!pack_feof(f))
21474 {
21475
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 25 times.
✓ Branch 10 taken 25 times.
✓ Branch 11 taken 25 times.
✓ Branch 12 taken 25 times.
✓ Branch 13 taken 25 times.
✓ Branch 14 taken 25 times.
✓ Branch 15 taken 25 times.
✓ Branch 16 taken 25 times.
✓ Branch 17 taken 25 times.
✓ Branch 18 taken 25 times.
✓ Branch 19 taken 25 times.
✓ Branch 20 taken 25 times.
✓ Branch 21 taken 25 times.
✓ Branch 22 taken 25 times.
✓ Branch 23 taken 25 times.
✓ Branch 24 taken 25 times.
600 switch(section_id)
21476 {
21477 case ID_RULES:
21478
21479 //rules
21480
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21481 {
21482 box_out("found.");
21483 box_eol();
21484 catchup=false;
21485 }
21486
21487 25 box_out("Reading Rules...");
21488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21489
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21490 25 box_out("okay.");
21491 25 box_eol();
21492 25 break;
21493
21494 case ID_STRINGS:
21495
21496 //strings
21497
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21498 {
21499 box_out("found.");
21500 box_eol();
21501 catchup=false;
21502 }
21503
21504 25 box_out("Reading Strings...");
21505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21506
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21507 25 box_out("okay.");
21508 25 box_eol();
21509 25 break;
21510
21511 case ID_MISC:
21512
21513 //misc data
21514
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21515 {
21516 box_out("found.");
21517 box_eol();
21518 catchup=false;
21519 }
21520
21521 25 box_out("Reading Misc. Data...");
21522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21523
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21524 25 box_out("okay.");
21525 25 box_eol();
21526 25 break;
21527
21528 case ID_TILES:
21529
21530 //tiles
21531
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21532 {
21533 box_out("found.");
21534 box_eol();
21535 catchup=false;
21536 }
21537
21538 25 box_out("Reading Tiles...");
21539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21540
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21541 25 box_out("okay.");
21542 25 box_eol();
21543 25 break;
21544
21545 case ID_COMBOS:
21546
21547 //combos
21548
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21549 {
21550 box_out("found.");
21551 box_eol();
21552 catchup=false;
21553 }
21554
21555 25 box_out("Reading Combos...");
21556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21557 25 combosread=true;
21558
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21559 25 box_out("okay.");
21560 25 box_eol();
21561 25 break;
21562
21563 case ID_COMBOALIASES:
21564
21565 //combo aliases
21566
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21567 {
21568 box_out("found.");
21569 box_eol();
21570 catchup=false;
21571 }
21572
21573 25 box_out("Reading Combo Aliases...");
21574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21575
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21576 25 box_out("okay.");
21577 25 box_eol();
21578 25 break;
21579
21580 case ID_CSETS:
21581
21582 //color data
21583
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21584 {
21585 box_out("found.");
21586 box_eol();
21587 catchup=false;
21588 }
21589
21590 25 box_out("Reading Color Data...");
21591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21592
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21593 25 box_out("okay.");
21594 25 box_eol();
21595 25 break;
21596
21597 case ID_MAPS:
21598
21599 //maps
21600
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21601 {
21602 box_out("found.");
21603 box_eol();
21604 catchup=false;
21605 }
21606
21607 25 box_out("Reading Maps...");
21608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21609 25 mapsread=true;
21610
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21611 25 box_out("okay.");
21612 25 box_eol();
21613 25 break;
21614
21615 case ID_DMAPS:
21616
21617 //dmaps
21618
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21619 {
21620 box_out("found.");
21621 box_eol();
21622 catchup=false;
21623 }
21624
21625 25 box_out("Reading DMaps...");
21626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21627
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21628 25 box_out("okay.");
21629 25 box_eol();
21630 25 break;
21631
21632 case ID_DOORS:
21633
21634 //door combo sets
21635
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21636 {
21637 box_out("found.");
21638 box_eol();
21639 catchup=false;
21640 }
21641
21642 25 box_out("Reading Doors...");
21643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21644
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21645 25 box_out("okay.");
21646 25 box_eol();
21647 25 break;
21648
21649 case ID_ITEMS:
21650
21651 //items
21652
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21653 {
21654 box_out("found.");
21655 box_eol();
21656 catchup=false;
21657 }
21658
21659 25 box_out("Reading Items...");
21660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21661
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21662
21663 25 box_out("okay.");
21664 25 box_eol();
21665 25 break;
21666
21667 case ID_WEAPONS:
21668
21669 //weapons
21670
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21671 {
21672 box_out("found.");
21673 box_eol();
21674 catchup=false;
21675 }
21676
21677 25 box_out("Reading Weapons...");
21678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21679
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21680 25 box_out("okay.");
21681 25 box_eol();
21682 25 break;
21683
21684 case ID_COLORS:
21685
21686 //misc. colors
21687
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21688 {
21689 box_out("found.");
21690 box_eol();
21691 catchup=false;
21692 }
21693
21694 25 box_out("Reading Misc. Colors...");
21695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21696
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21697 25 box_out("okay.");
21698 25 box_eol();
21699 25 break;
21700
21701 case ID_ICONS:
21702
21703 //game icons
21704
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21705 {
21706 box_out("found.");
21707 box_eol();
21708 catchup=false;
21709 }
21710
21711 25 box_out("Reading Game Icons...");
21712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21713
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21714 25 box_out("okay.");
21715 25 box_eol();
21716 25 break;
21717
21718 case ID_INITDATA:
21719
21720 //initialization data
21721
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21722 {
21723 box_out("found.");
21724 box_eol();
21725 catchup=false;
21726 }
21727
21728 25 box_out("Reading Init. Data...");
21729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21730
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21731 25 box_out("okay.");
21732 25 box_eol();
21733
21734
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21735 {
21736
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 12 times.
25 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21737 {
21738 12 setupsubscreens();
21739
21740
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<MAXDMAPS; ++i)
21741 {
21742 6144 int32_t type=DMaps[i].type&dmfTYPE;
21743
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6132 times.
6144 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21744 6144 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21745 6144 }
21746 12 }
21747 25 }
21748
21749
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepall&&!get_bit(skip_flags, skip_sfx))
21750 {
21751 25 setupsfx();
21752 25 }
21753
21754
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21755 {
21756 25 init_item_drop_sets();
21757 25 }
21758
21759
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepall&&!get_bit(skip_flags, skip_favorites))
21760 {
21761 25 init_favorites();
21762 25 }
21763
21764 25 break;
21765
21766 case ID_GUYS:
21767
21768 //guys
21769
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21770 {
21771 box_out("found.");
21772 box_eol();
21773 catchup=false;
21774 }
21775
21776 25 box_out("Reading Custom Guy Data...");
21777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21778
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21779 25 box_out("okay.");
21780 25 box_eol();
21781 25 break;
21782
21783 case ID_HEROSPRITES:
21784
21785 //player sprites
21786
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21787 {
21788 box_out("found.");
21789 box_eol();
21790 catchup=false;
21791 }
21792
21793 25 box_out("Reading Custom Player Sprite Data...");
21794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21795
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21796 25 box_out("okay.");
21797 25 box_eol();
21798 25 break;
21799
21800 case ID_SUBSCREEN:
21801
21802 //custom subscreens
21803
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21804 {
21805 box_out("found.");
21806 box_eol();
21807 catchup=false;
21808 }
21809
21810 25 box_out("Reading Custom Subscreen Data...");
21811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21812
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21813 25 box_out("okay.");
21814 25 box_eol();
21815 25 break;
21816
21817 case ID_FFSCRIPT:
21818
21819 //Freeform combo scripts
21820
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21821 {
21822 box_out("found.");
21823 box_eol();
21824 catchup=false;
21825 }
21826
21827 25 box_out("Reading FF Script Data...");
21828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21829
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21830 25 box_out("okay.");
21831 25 box_eol();
21832 25 break;
21833
21834 case ID_SFX:
21835
21836 //SFX data
21837
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21838 {
21839 box_out("found.");
21840 box_eol();
21841 catchup=false;
21842 }
21843
21844 25 box_out("Reading SFX Data...");
21845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21846
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21847 25 box_out("okay.");
21848 25 box_eol();
21849 25 break;
21850
21851 case ID_MIDIS:
21852
21853 //midis
21854
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21855 {
21856 box_out("found.");
21857 box_eol();
21858 catchup=false;
21859 }
21860
21861 25 box_out("Reading Tunes...");
21862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21863
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21864 25 box_out("okay.");
21865 25 box_eol();
21866 25 break;
21867
21868 case ID_CHEATS:
21869
21870 //cheat codes
21871
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21872 {
21873 box_out("found.");
21874 box_eol();
21875 catchup=false;
21876 }
21877
21878 25 box_out("Reading Cheat Codes...");
21879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21880
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21881 25 box_out("okay.");
21882 25 box_eol();
21883 25 break;
21884
21885 case ID_ITEMDROPSETS:
21886
21887 //item drop sets
21888
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21889 {
21890 box_out("found.");
21891 box_eol();
21892 catchup=false;
21893 }
21894
21895 25 box_out("Reading Item Drop Sets...");
21896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21897
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21898 25 box_out("okay.");
21899 25 box_eol();
21900 25 break;
21901
21902 case ID_FAVORITES:
21903
21904 //favorite combos and combo aliases
21905
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(catchup)
21906 {
21907 box_out("found.");
21908 box_eol();
21909 catchup=false;
21910 }
21911
21912 25 box_out("Reading Favorite Combos...");
21913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
21914
1/5
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
25 checkstatus(ret);
21915 25 box_out("okay.");
21916 25 box_eol();
21917 25 break;
21918
21919 default:
21920 if(!catchup)
21921 {
21922 box_out("Bad token! Searching...");
21923 box_eol();
21924 }
21925
21926 catchup=true;
21927 break;
21928 }
21929
21930
21931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
600 if(catchup)
21932 {
21933 //section id
21934 section_id=(section_id<<8);
21935
21936 if(!p_getc(&tempbyte,f,true))
21937 {
21938 return qe_invalid;
21939 }
21940
21941 section_id+=tempbyte;
21942 }
21943
21944 else
21945 {
21946 //section id
21947
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 575 times.
600 if(!pack_feof(f))
21948 {
21949
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(!p_mgetl(&section_id,f,true))
21950 {
21951 return qe_invalid;
21952 }
21953 575 }
21954 }
21955 }
21956 25 }
21957 else
21958 {
21959 //rules
21960 box_out("Reading Rules...");
21961 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21962 checkstatus(ret);
21963 box_out("okay.");
21964 box_eol();
21965
21966 //strings
21967 box_out("Reading Strings...");
21968 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21969 checkstatus(ret);
21970 box_out("okay.");
21971 box_eol();
21972
21973 //door combo sets
21974 box_out("Reading Doors...");
21975 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21976 checkstatus(ret);
21977 box_out("okay.");
21978 box_eol();
21979
21980 //dmaps
21981 box_out("Reading DMaps...");
21982 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21983 checkstatus(ret);
21984 box_out("okay.");
21985 box_eol();
21986
21987 // misc data
21988 box_out("Reading Misc. Data...");
21989 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21990 checkstatus(ret);
21991 box_out("okay.");
21992 box_eol();
21993
21994 //items
21995 box_out("Reading Items...");
21996 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21997 checkstatus(ret);
21998 box_out("okay.");
21999 box_eol();
22000
22001 //weapons
22002 box_out("Reading Weapons...");
22003 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22004 checkstatus(ret);
22005 box_out("okay.");
22006 box_eol();
22007
22008 //guys
22009 box_out("Reading Custom Guy Data...");
22010 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22011 checkstatus(ret);
22012 box_out("okay.");
22013 box_eol();
22014
22015 //maps
22016 box_out("Reading Maps...");
22017 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22018 mapsread=true;
22019 checkstatus(ret);
22020 box_out("okay.");
22021 box_eol();
22022
22023 //combos
22024 box_out("Reading Combos...");
22025 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22026 combosread=true;
22027 checkstatus(ret);
22028 box_out("okay.");
22029 box_eol();
22030
22031 //color data
22032 box_out("Reading Color Data...");
22033 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22034 checkstatus(ret);
22035 box_out("okay.");
22036 box_eol();
22037
22038 //tiles
22039 box_out("Reading Tiles...");
22040 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22041 checkstatus(ret);
22042 box_out("okay.");
22043 box_eol();
22044
22045 //midis
22046 box_out("Reading Tunes...");
22047 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22048 checkstatus(ret);
22049 box_out("okay.");
22050 box_eol();
22051
22052 //cheat codes
22053 box_out("Reading Cheat Codes...");
22054 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22055 checkstatus(ret);
22056 box_out("okay.");
22057 box_eol();
22058
22059 //initialization data
22060 box_out("Reading Init. Data...");
22061 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22062 checkstatus(ret);
22063 box_out("okay.");
22064 box_eol();
22065
22066 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22067 {
22068 setupsubscreens();
22069
22070 for(int32_t i=0; i<MAXDMAPS; ++i)
22071 {
22072 int32_t type=DMaps[i].type&dmfTYPE;
22073 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22074 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22075 }
22076 }
22077
22078 box_out("Setting Up Default Sound Effects...");
22079
22080 if(keepall&&!get_bit(skip_flags, skip_sfx))
22081 setupsfx();
22082
22083 box_out("okay.");
22084 box_eol();
22085
22086 //player sprites
22087 box_out("Reading Custom Player Sprite Data...");
22088 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22089 checkstatus(ret);
22090 box_out("okay.");
22091 box_eol();
22092
22093 box_out("Setting Up Default Item Drop Sets...");
22094 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22095 box_out("okay.");
22096 box_eol();
22097 }
22098
22099 25 init_spritelists();
22100
22101 // check data
22102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(f)
22103 {
22104 25 pack_fclose(f);
22105 25 }
22106
22107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!oldquest)
22108 {
22109
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(exists(tmpfilename))
22110 {
22111 delete_file(tmpfilename);
22112 }
22113 25 }
22114
22115
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 if(fixffcs && combosread && mapsread)
22116 {
22117 for(int32_t i=0; i<map_count; i++)
22118 {
22119 for(int32_t j=0; j<MAPSCRS; j++)
22120 {
22121 for(int32_t m=0; m<32; m++)
22122 {
22123 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22124 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22125 }
22126 }
22127 }
22128 }
22129
22130
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 2 times.
25 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22131 {
22132 2 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22133 2 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22134 2 zinit.cont_heart=100;
22135 2 zinit.start_heart=zinit.hc;
22136 2 }
22137
22138 25 box_out("Done.");
22139 25 box_eol();
22140 25 box_end(false);
22141
22142 // if (keepall==true||!get_bit(skip_flags, skip_header))
22143
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepall&&!get_bit(skip_flags, skip_header))
22144 {
22145 25 memcpy(Header, &tempheader, sizeof(tempheader));
22146 25 }
22147
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22148 {
22149 25 ZI.copyFrom(tempzi);
22150 25 }
22151
22152
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(!keepall||get_bit(skip_flags, skip_maps))
22153 {
22154 map_count=old_map_count;
22155 }
22156
22157
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(!keepall||get_bit(skip_flags, skip_rules))
22158 {
22159 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22160 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22161 }
22162
22163
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(!keepall||get_bit(skip_flags, skip_midis))
22164 {
22165 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22166 }
22167
22168
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(deletefilename[0] && exists(deletefilename))
22169 {
22170 25 delete_file(deletefilename);
22171 25 }
22172
22173 //Debug FFCore.quest_format[]
22174 25 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22175 25 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22176 25 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22177 25 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22178 25 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22179 25 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22180 25 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22181 25 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22182 25 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22183 25 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22184 25 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22185 25 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22186 25 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22187 25 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22188 25 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22189 25 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22190 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22191 25 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22192 25 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22193 25 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22194 25 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22195 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22196 25 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22197 25 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22198 25 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22199 25 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22200 25 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22201 25 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22202 25 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22203 25 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22204 //Print metadata for versions under 2.10 here. Bleah.
22205
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if( FFCore.quest_format[vZelda] < 0x210 )
22206 {
22207 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22208
22209 switch(FFCore.quest_format[vZelda])
22210 {
22211 case 0x193:
22212 {
22213 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22214 }
22215 case 0x192:
22216 {
22217 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22218 }
22219 case 0x190:
22220 {
22221 zprint2("Last saved in ZC Editor Version: 1.90");
22222 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22223 else zprint2("\n");
22224 break;
22225 }
22226 case 0x188:
22227 {
22228 zprint2("Last saved in ZC Editor Version: 1.88");
22229 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22230 else zprint2("\n");
22231 break;
22232 }
22233 case 0x187:
22234 {
22235 zprint2("Last saved in ZC Editor Version: 1.87");
22236 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22237 else zprint2("\n");
22238 break;
22239 }
22240 case 0x186:
22241 {
22242 zprint2("Last saved in ZC Editor Version: 1.86");
22243 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22244 else zprint2("\n");
22245 break;
22246 }
22247 case 0x185:
22248 {
22249 zprint2("Last saved in ZC Editor Version: 1.85");
22250 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22251 else zprint2("\n");
22252 break;
22253 }
22254 case 0x184:
22255 {
22256 zprint2("Last saved in ZC Editor Version: 1.84");
22257 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22258 else zprint2("\n");
22259 break;
22260 }
22261 case 0x183:
22262 {
22263 zprint2("Last saved in ZC Editor Version: 1.83");
22264 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22265 else zprint2("\n");
22266 break;
22267 }
22268 case 0x182:
22269 {
22270 zprint2("Last saved in ZC Editor Version: 1.82");
22271 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22272 else zprint2("\n");
22273 break;
22274 }
22275 case 0x181:
22276 {
22277 zprint2("Last saved in ZC Editor Version: 1.81");
22278 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22279 else zprint2("\n");
22280 break;
22281 }
22282 case 0x180:
22283 {
22284 zprint2("Last saved in ZC Editor Version: 1.80");
22285 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22286 else zprint2("\n");
22287 break;
22288 }
22289 default:
22290 {
22291 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22292 }
22293 }
22294 }
22295
22296 25 return qe_OK;
22297
22298 invalid:
22299 box_out("error.");
22300 box_eol();
22301 box_end(true);
22302
22303 if(f)
22304 {
22305 pack_fclose(f);
22306 }
22307
22308 if(!oldquest)
22309 {
22310 if(exists(tmpfilename))
22311 {
22312 delete_file(tmpfilename);
22313 }
22314
22315 if(deletefilename[0] && exists(deletefilename))
22316 {
22317 delete_file(deletefilename);
22318 }
22319 }
22320
22321 return qe_invalid;
22322
22323 25 }
22324
22325 25 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22326 {
22327 25 loading_qst_name = filename;
22328 25 loading_qst_num = qst_num;
22329 25 loadquest_report = report;
22330 25 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, compressed, encrypted, keepall, skip_flags,printmetadata);
22331 25 load_tmp_zi = NULL;
22332 25 loading_qst_name = NULL;
22333 25 loadquest_report = false;
22334 25 loading_qst_num = 0;
22335 25 return ret;
22336 }
22337 /*** end of qst.cc ***/
22338
22339